Using menu_valid_path function

Events happening in the community are now at Drupal community events on www.drupal.org.
philbar's picture

I can't for the life of my figure out how to use the menu_valid_path.

I'm creating a dynamic navigation block and would like to check that paths exist before displaying links.

<?php
$path
'/industrial/odor-control/description';
if
menu_valid_path($path){
  print
'<li><a href="'. $path .'"><span class=\"tab\">Description</span></a></li>'
}
?>

What am I doing wrong? Does this function not work in blocks? Am I using the function wrong?

All I get is this parse error:
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/bioworld/public_html/includes/common.inc(1695) : eval()'d code on line 23

Comments

Looks like you're missing

bestrank's picture

Looks like you're missing parentheses on your if statement, should be

if(menu_valid_path($path)) {

and also need a semicolon at the end of the print statement

Thanks! I've contributed my

philbar's picture

Thanks!

I've contributed my code example to the documentation:

http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_valid_...

San Diego DUG

Group categories

Event Classifications

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: