--- phptemplate.engine.orig Tue Mar 8 17:13:40 2005 +++ phptemplate.engine Tue Mar 8 17:25:31 2005 @@ -97,6 +97,17 @@ $header = array(t('link text'), t('url'), t('description')); $form = t('

Due to incompatibilies in the handling of primary, and secondary links in PHPTemplate, these links need to specified seperately using the form below. Even though this is on the theme-specific configuration page, these settings will take affect in all themes using PHPTemplate.

'); +$menu = menu_get_menu(); + $menus = array('' => 'None: Define Manually Below'); + foreach ($menu['items'][0]['children'] as $choice) { + if ($choice > 1) { + // Don't use menu 1 (navigation) + $menus = $menus + array($choice => $menu['visible'][$choice]['title']); + } + } + + $form .= form_select('Use Menu', 'phptemplate_menu_links', variable_get('phptemplate_menu_links', ''), $menus, $description = 'This will allow the secondary links to change depending on what primary link is active. It will override any links defined below.'); + foreach (array('Primary', 'Secondary') as $utype) { $rows = array(); @@ -153,6 +164,27 @@ $links['primary'] = array(); $links['secondary'] = array(); + + if (variable_get('phptemplate_menu_links', '')) { + $pid = variable_get('phptemplate_menu_links', ''); + $menu = menu_get_menu(); + if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { + foreach ($menu['visible'][$pid]['children'] as $mid) { + $style = (count($menu['visible'][$mid]['children']) ? ((menu_in_active_trail($mid) || ($menu['visible'][$mid]['type'] & MENU_EXPANDED)) ? 'expanded' : 'collapsed') : 'leaf'); + $style .= (drupal_get_normal_path($menu['items'][$mid]['path']) == $_GET['q']) ? ' active' : ''; + $links['primary'][] = "
  • ".theme('menu_item', $mid).'
  • '; + if (menu_in_active_trail($mid)) { + if (isset($menu['visible'][$mid]) && $menu['visible'][$mid]['children']) { + foreach ($menu['visible'][$mid]['children'] as $sid) { + $sublink = (drupal_get_normal_path($menu['items'][$sid]['path']) == $_GET['q']) ? '
  • ' : '
  • '; + $links['secondary'][] = $sublink.theme('menu_item', $sid).'
  • '; + } + } + } + } + } + } + else { foreach (array('primary', 'secondary') as $type) { //Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format. $value = variable_get('phptemplate_' . $type . '_links', ''); @@ -168,7 +200,7 @@ if (!empty($value['description'][$i])) { $attributes['title'] = $value['description'][$i]; } - $links[$type][] = l($value['text'][$i], $value['link'][$i], $attributes); + $links[$type][] = '
  • '.l($value['text'][$i], $value['link'][$i], $attributes).'
  • '; } } }