Hello,

My second post. Yahooo. this is a refinement of another post but I couldn't find a way to edit the other post.

I have the code below for a secondary nav. It works perfectly. I am just missing one important piece of information. See where it says "Need current page listed here"? I would like to display the name of the main nav item that this secondary nav is organized under. Is there a piece of PHP code that I can put in there to make that display? Thanks for looking at this.

<?php if (is_array($secondary_links)) : ?>
	<div class="titleSubnav">Need primary nav item listed here</div>					
	<div class="navContainer">						
		<ul class="subnav">			
			<?php foreach ($secondary_links as $link): ?>
			<li><?php print $link?></li>
			<?php endforeach; ?>
		</ul>									
	</div> 
<?php endif; ?>

Comments

mikemccaffrey’s picture

I am fairly new at drupal, and was looking to do the exact same thing. Here is the way I solved it for my site:

Since the title of the secondary navigation should just be the active link in the primary menu, I just added this code into the spot where you have "Need pimary nav item listed here":

<?php 
  foreach ($primary_links as $key => $value) 
    if (strstr($key,"active")) 
      print $value;
?>

Hope this helps!

Mike

JoshLangner’s picture

This thread solves my [related] problem as well (http://drupal.org/node/75486).

Great work. Now the question is, how do you just get the title (not the complete URL etc.)? For example, doing a var_dump($primary_links) shows the following:

string(95) "<a href="/drpperformance/node/6" title="This is our Services page." class="active">Services</a>"

All we need here is the title, not the whole link.

mikemccaffrey’s picture

To just get the title and not the whole link, take my code above and replace print $value; with print strip_tags($value);.

protitude’s picture

This returned an Array in Drupal 6, here's the code that worked for me:

<?php
     foreach ($primary_links as $key => $value)
     if (strstr($key,"active"))
     print $value['title']; 
?>

=-=-=-=-=-=-=-
Miles

mikemccaffrey’s picture