I am trying to put a if statement to the page.tpl.com in which if the current page is "exaple" print something on the screen

my path is like this mydomain.com/test-php

so if the page is /test-php print something like this

	if (!(arg(0) == 'test' && arg(1) == 'php' )) {
  						  print "Hello World";   }
				?>

Comments

ionut.alexuc’s picture

If you have /test-php

It measn arg(0)=test-php
and arg(1)=EMPTY

Your if statement works for path:
/test/php

werushka’s picture

thank you very much for your fast reply

I have this in page.tpl.php

<?php
if (!(arg(0) == 'test-php')) {
    print "Hello World";   }
?>

but it prints Hello World in every-page and does not care about the arg

ionut.alexuc’s picture

It will not print the Hello world on the page: /test-php

Your condition is wrong, it should be:

<?php
if ((arg(0) != 'test-php')) {
    print "Hello World";   }
?>
werushka’s picture

thanks for your reply ionut.alexuc

well you are right I forgot the ! infront of the arg but this code still does not work but it should work

werushka’s picture

actually it should be like this

<?php
if ((arg(0) == 'test-php')) {
    print "Hello World";   }
?>

I want to print Hello world only in test-php but still it does not work :(

ionut.alexuc’s picture

Try to print arg(0) and see the value.

Are you sure you edit the right file?

werushka’s picture

it just prints node ??

ionut.alexuc’s picture

yeah :)

your /test-php is a node page.
It has an internal path like: node/100

you have to print arg(1) and see the node ID.

then change your condition as:

if ( (arg(0) == 'node') && (arg(1) == 100) && (!arg(3))) {
// ....
}
werushka’s picture

yep I got it it is 130 put when I put this

<?php
if ( (arg(1) == 'node') && (arg(1) == 130) && (!arg(3))) {
 print "Hello World"; } 

?>

it still does not work :((

werushka’s picture

i got the logic :)

<?php
if ( (arg(0) == 'taxonomy') && (arg(1) == 'term') && (!arg(3) == 130)) {
	print "hello world";   }
?>

works perfectly

werushka’s picture

damn it actually shows in every taxonomy/term/ page and it does not care about the taxonomy/term/130

:(

werushka’s picture

damn I think I am sooo sleepy

<?php
if ( (arg(0) == 'taxonomy') && (arg(1) == 'term') && (arg(2) == 130)) {
	print "hello world";   }
?>

I typed arg 3 in the previous post

soheil-yasrebi’s picture

here's a cleaner version:

if(arg(0) == 'taxonomy' && arg(1) == 'term' && arg(2) == 130) print "hello world";