Posted by doors on August 26, 2010 at 6:20pm
In Openpublish 2.0 the main menu links had a class for the forst link and last link.
Openpublish 2.2 does not have these classes which are essential for some creative css work.
How can I add these class to the first and last links in the menu?
I see that print theme('openpublish_menu', $expanded_primary_links); is being used instead of print theme('links', $primary_links, array('class' => 'links primary-links')) which doesn't seem to use the openpublish_theme_menu_item() function.
How can I accomplish this?
Comments
Good call for the first /
Good call for the first / last class in the expanded menu. Since OP 2.1 it is enabled by default, but should it not be set, the theme will use the regular $primary_links.
Here's a way to add these classes for now by adding some logic to your tpl:
1 - copy openpublish-menu.tpl.php from sites/all/modules/openpublish_core/openpublish_menu to your active theme (openpublish_theme or whatever child theme you may have)
2 - add this right after lines 6-7 where $title_link is set:
static $i = 1;$position_class = "";
if ($i === 1) {$position_class = "first";}
elseif ($i == sizeof($expanded_primary_links)) {$position_class = "last";}
$i++;
3 - change this line:
<li class="first-level <?php print ($top_item->active ? $top_item->active : "off"); ?>">to
<li class="first-level <?php print ($top_item->active ? $top_item->active : "off"); ?> <?php print $position_class; ?>">Later on I will take care of moving this into the preprocessor that generates $expanded_primary_links.
I went ahead an installed
I went ahead an installed Nice Menu because I couldn't get any answers.
Thanks for the response. I might use this solution for my other project.