I have a block being called from my page.tpl.php file to display on the front page. I'm using if ($is_front) : to check that the front page is being displayed. My problem is that I only want the block to display when the pager is on page 1, not when the user is on subsequent pages (i.e. node?page=2, node?page=3 etc.).

I thought about trying to get around this by using custom views or the front page module, but thought I might run into the same issue. Any suggestions would be greatly appreciated.

You can see an example at http://dev.dreamworks.org

Comments

klapper’s picture

if ($node->nid == 1)

ericprk’s picture

Didn't work. I thought == tested for not. nid = 1 did recognize that it was the front page (I haven't changed the front page node), but the block still showed up on page 2, page 3 etc.

klapper’s picture

maybe you did at the wrnog place. You may enter php-code in the block visibility settings in your blocks configuration.

== tests for equal, != not equal, = is assignment operator, ! is not

ericprk’s picture

I think I need to check at the first argument level. I came across this snippet and am just trying to figure out how to modify it (I don't know php well and my syntax skills stink):

if (arg(0) == 'node' && is_numeric(arg(1))

klapper’s picture

this snippest belongs to page.tpl.php. At that point $node is not set.


if (arg(0) == 'node' && is_numeric(arg(1))
  $node = node_load(arg(1));

After that you may check $node->type, $node->nid, ...

Or just do


if (arg(0) == 'node' && is_numeric(arg(1)) && arg(1) == 1) {

  // do what you want, e.g. display your block
}
nevets’s picture

Change

<?php
if ($is_front) :
?>

to

$page = $_GET['page'];
if ($is_front  && !$page) :

ericprk’s picture

It worked!!! Thanks Nevets you are so rocking my world today!

zanematthew’s picture

does this function

$_GET['page'];

get the current drupal page? i've been looking for something like this, I am currently using a custom built function to get the current URL which is a bit chunky