Arg function does not use url alias

I am running Drupal 6 and I am using PHP for block visibility.

<?php
$city = arg(0);
$page = arg(1);

if ($city == 'tampa' && $page != 'art'){
return 'TRUE';
}
else{
return FALSE;
}
?>

      

I was having problems with this block of code, so I decided to insert:

<?php print arg(0).arg(1); ?>

      

in my page.tpl.php. I found that on some of my pages arg (0) was showing "node" when the url is actually "tampa", and of course arg (1) is showing the node id.

However, on other pages, like my calendar, arg (0) actually shows 'tampa' instead of 'node'.

I have used this a lot in the past and have never encountered this problem. Is there a reason why Drupal is ignoring my aliases on certain pages? If so, how can I fix this?

+2


a source to share


1 answer


I didn't have any answers for this, but I developed a hack.

$path = 'node' . "/" . $node->nid;
drupal_get_path_alias($path);

      



from there I was able to use PHP's string parsing functions to get the actual alias.

+1


a source







All Articles