How do I distinguish menu items without children and display different content in panels or views? I have a taxonomy based menu (3 tiers) that displays a specific content type.  Content items are always tagged at the lowest level child (*) so when the menu items are selected a range of content is displayed. 

top-level | mid-level1 | child1*
          |            | child2*
          |
          | mid-level2 - child3*
          |
          | child4*


When the parent levels are selected, I would like a summary page for the parent to show. I am using views and panels and getting the lowest level children to show is easily accomplished, but how do I set a filter or context to determine if the view is not at the lowest level?

Panels exposes a context that selects content with a parent (or not) so I can easily identify the top level menu selections, but the bottom children can occur at either level two or three and there is no context for 'has children'.

What can I use as a context to select the parents and which hook to use?
This is an excellent example of a custom Ctools plugin. In this case, our plugin type is "Access". The below is copied from "term_has_parent", and adopted to search for the reverse. It could probably be improved with some more robust error checking.

In Panels, you will get a new "Selection Rule", so that you can distinguish between terms that have children, from those that don't.

&lt;?php
/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'title' =&gt; t("Taxonomy: term has child(ren)"),
  'description' =&gt; t('Control access if a term has children.'),
  'callback' =&gt; 'term_has_child_ctools_access_check',
  'default' =&gt; array('negate' =&gt; 0),
  'summary' =&gt; 'term_has_child_ctools_access_summary',
  'required context' =&gt; new ctools_context_required(t('Term'), array('taxonomy_term', 'terms')),
);

/**
 * Check for access.
 */
function term_has_child_ctools_access_check($conf, $context) {
  $children = db_select('taxonomy_term_hierarchy', 't')
    -&gt;fields('t')
    -&gt;condition('parent', $context-&gt;data-&gt;tid)
    -&gt;range(0, 1)
    -&gt;execute()
    -&gt;fetchAssoc();

  return count($children) &gt; 1;
}

/**
 * Provide a summary description based upon the checked terms.
 */
function term_has_child_ctools_access_summary($conf, $context) {
  return 'Returns true if the current term has children';
}


If you don't know how to use a custom Ctools plugin, I suggest that is the topic of another question.