I currently am using the public_nav helper function to generate a menu for my site.
It currently looks something like:
<?php echo public_nav(array('Home' => uri(''), 'Browse Items' => uri('items',array('sort_field' => 'id')), 'Collections'=>uri('collections'), 'Tags' => uri('items/tags?sort=alpha'),'Add Your Own'=>uri('contribution'),'About'=>uri('about'),'Help'=>uri('help'),'Some External Site'=>'http://www.someexternalsite.com')); ?>
I'd like to have the 'Some External Site' link open a new tab, but I can't figure out how.
Thanks,
Andy
Unfortunately, I don't think that there's a way to do that with the function
I've recently come back to this issue because not only do we want to have the Contact Us link open in a new tab, but we want to add analytics event tracking code to this link. I'm now thinking of adding a custom function based off the public_nav function.
function my_public_nav(array $navArray, $navType=null, $maxDepth = 0)
{
if ($navType) {
$filterName = 'public_navigation_' . $navType;
$navArray = apply_filters($filterName, $navArray);
}
return nav($navArray, $maxDepth);
$contactlink='<li><a href="contactus.html" target="new" analytics tracking code>Contact Us</a></li>';
return $contactlink;
}
Basically this will just append a Contact Us link in the list created by the nav function. I haven't had a chance to try it, but I think it should work. Then in my header.php file instead of using public_nav, I'd use my_public_nav.
Scratch the above post.
Much simpler to just add <li><a href="contactus.html" target="new" analytics tracking code>Contact Us</a></li>
to the header.php file after:
<?php echo public_nav(array('Home' => uri(''), 'Browse Items' => uri('items',array('sort_field' => 'id')), 'Collections'=>uri('collections'), 'Tags' => uri('items/tags?sort=alpha'),'Add Your Own'=>uri('contribution'),'About'=>uri('about'),'Help'=>uri('help'),'Some External Site'=>'http://www.someexternalsite.com')); ?>
Nothing like making things more complicated.