Adding activemenu to my own menus
Julien PHAM - October 14, 2008 - 18:44
| Project: | Active menus |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi,
in a block I have created menus with php code.
Is there a way to add activemenu support with those hand made menus ? How ?
Thanks

#1
Mmm I have read the README about how to add our own activemenus.
I have build some menus myself in php, but not with the drupal menu functions, just by using html code.
Is it still possible then to add activemenus?
Thanks
EDIT : here is the code of my block :
<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
* @file views-view-list.tpl.php
* Default simple view template to display a list of rows.
*
* - $title : The title of this group of rows. May be empty.
* - $options['type'] will either be ul or ol.
* @ingroup views_templates
*/
$cLink = request_uri();
print '<div class="content"><ul class="menu">';
$vTitle='Les Mercuriales au quotidien';
$vLink='les-mercuriales-au-quotidien';
$options = array();
$options['title'] .= '';
$options['attributes']['class'] .= ' activemenu-processed';
if ($cLink == '/'.$vLink) {$options['attributes']['class'] .= ' active';}
if (($cLink == '/les-mercuriales-au-quotidien') || (substr($cLink,0,14) == '/cotations-du-')):
print '<li class="expanded last active-trail">'.l($vTitle,$vLink,$options);
else:
print '<li class="collapsed last active-trail">'.l($vTitle,$vLink,$options);
endif;
print '<ul class="menu">';
if (($cLink == '/les-mercuriales-au-quotidien') || (substr($cLink,0,14) == '/cotations-du-')):
foreach ($rows as $id => $row):
$options = array();
$working=$row;
$myarray = explode('</div>',$working);
$search = preg_match_all('#<span class="field-content">(.*?)<\/span>#s', $working, $match);
if ($search) {
$vTitle = $match[1][0];
$vLink = $match[1][1];
$search = preg_match('#<a href="\/(.*?)"#s', $vLink, $match);
if ($search) {
$vLink = $match[1];
}
}
$link['title'] = $vTitle;
$link['href'] = $vLink;
$options += array(
'attributes' => array(),
'html' => FALSE,
);
$options['title'] .= '';
if ($cLink == '/'.$vLink) {$options['attributes']['class'] .= ' active';}
print '<li class="leaf first">'.l($vTitle,$vLink,$options).'</li>';
endforeach;
endif;
print '</ul></li></ul></div>';
?>
#2
Yes. You need to put your custom menu in a module and follow the steps in the README.