开发者

arg function not using URL alias

开发者 https://www.devze.com 2022-12-28 00:20 出处:网络
I am running Drupal 6, and I\'m using PHP for block visibility. <?php $city = arg(0); $page = arg(1);

I am running Drupal 6, and I'm 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 trouble with this block of code, so I decided to insert:

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

in my page.tpl.php. What I found was that on some of my pages, arg(0) was showing 'node' when the URL is actually 't开发者_运维百科ampa', and of course, arg(1) is showing the node ID.

However, on other pages, such as my calendar, arg(0) is actually showing 'tampa' instead of 'node'.

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


I didn't get any responses on this, but I worked out a hack.

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消