This seems to be new with Drupal 6.x as I used this in a previous project.

I'm trying to place a custom secondary links menu into the left sidebar of page.tpl.php (or any menu for that matter)

<?php print theme('links', $custom_secondary_links, $attributes = array('class' => 'menulinks')) ?>

with page preprocess $vars declared in my sub-theme's template.php

$vars['custom_secondary_links'] = menu_navigation_links('menu-my-custom-menu',1);

I modified the if $left conditional to include this and it shows, but apparently to arrive at body classes other than no-sidebars, blocks needs to be invoked. (Really?)

<?php if ($left || $custom_secondary_links): ?>

The menu renders, but the body classes remain at an unchanged state. Here, it's 'no-sidebars'

Is there anything I can do to get the sidebar to render placing content in the page.tpl.php ?

Or maybe can I somehow get this to work via blocks (it doesn't as is)?

Thanks.

Comments

brst t’s picture

Or maybe can I somehow get this to work via blocks (it doesn't as is)?

Found that answer here :
http://drupal.org/node/86890#comment-1211618

Or in my case, it's a secondary, not a tertiary, so it looks like this : 1 in place of the 2 and with that additional id #sidebar-nav tossed in for good measure :

<?php
$mymenu = variable_get('menu-my-custom-menu_source', 'menu-my-custom-menu');
 print theme('links',
    menu_navigation_links($mymenu, 1),
    array('class' => 'menulinks', 'id' => 'sidebar-nav'));
?>

Substitute your own menu names (hover links at admin/build/menu/list or use devel module) add your version of the above to a php-filtered block and save it to your left or right region. Ding.

brst t’s picture

Title: Custom menu parent link in custom menu block explained » no-sidebars with content placed in sidebar in page.tpl.php

Changing the title

brst t’s picture

Title: no-sidebars with content placed in sidebar in page.tpl.php » Custom menu parent link in custom menu block explained

Now I want to print this with the parent menu item -- and unlike menu_block, I want that parent item in the menu to be a link.

And since my lengthy searches for how to accomplish this came up with nothing but old Drupal 5 solutions, I thought I'd post my solution.

Using devel module with the 'Execute PHP' block enabled. I loaded up my node and cranked this through that enabled Execute PHP block :

print_r(menu_get_active_trail())

Lovely. I see my parent item in ['1']. And now I can extract the building blocks to make my desired parent menu item link :

$myactive_trail = menu_get_active_trail();
print ($myactive_trail['1']['link_path']);
print ($myactive_trail['1']['link_title']);

So into my custom menu block, ahead of the code in the previous post, I add this:

<?php $myactive_trail = menu_get_active_trail(); ?> 
 <div class="mymenuparent">
  <a href="<?php print ($myactive_trail['1']['link_path']); ?>"><?php print ($myactive_trail['1']['link_title']); ?></a>
 </div>

Note the additional class 'mymenuparent'. Now I can style it like a header or, in my case, to match the rest of the menu and share attributes with #sidebar-nav ul.menu and #sidebar-nav li

And my link_path should be listed as its url_alias, so my link code is wrapped up in a neat little url() instead.
print (url($myactive_trail['1']['link_path']));

brst t’s picture

Title: no-sidebars with content placed in sidebar in page.tpl.php » Custom menu parent link in custom menu block explained
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.