开发者

On Drupal 7, in a custom block, how can I find out the current page?

On Drupal 6, I used to have a custom PHP block which accessed arg(0), to detect which page the user was currently on. To find out whether the user was on the front page, I used:

if (arg(0) == '' || arg(0) == 'home') :

However, this test doesn't appear to work on Drupal 7, as the arg(0) returns node. I was wondering whether there is a better way to check the page - for exam开发者_如何转开发ple the template engine's $is_front which I can access at a block level to check whether the page is the front one.

Thanks for your help,

J


In Drupal 7 there is a function called drupal_is_front_page.

Also as usual you can show/hide the block from the front page simply by providing <front> in the list of paths in your block's configuration page.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜