Topic: Show only in index.php

I have an image in main.tpl that I would like to only be displayed on index.php (not the other pages).

Is there any way that I can do this?

Would it be best to code for the image in index.php itself, instead of main.tpl? If so, how do I insert an image into index.php (im not too good with php)?

Re: Show only in index.php

Anyone know???

Re: Show only in index.php

I would suggest you to consider including a .php script for that, using the following code in the .tpl: <pun_include "banner.php">

Replace banner.php with a script you upload into ./include/user/

One such script might perhaps contain something like:

<?php

switch(basename($_SERVER['PHP_SELF'])):
  case 'index.php':
    $banner_img = PUN_ROOT.'img/banner_index.png';  
    break;
  default:
    $banner_img = PUN_ROOT.'img/banner_other.png';
endswitch;

echo '<img src="'.$banner_img.'" alt="Banner image" />';
  
?>

Re: Show only in index.php

Alright, thanks alot CodeXP!

I'll give it a go...

Re: Show only in index.php

Hey, sorry im not very good with PHP...

How would I make it not show anything, instead of show a different image on the other pages?

Re: Show only in index.php

reubster wrote:

Hey, sorry im not very good with PHP...

How would I make it not show anything, instead of show a different image on the other pages?

Here you go smile

<?php

if(basename($_SERVER['PHP_SELF']) == 'index.php') {
  echo '<img src="'.PUN_ROOT.'img/banner_index.png" alt="Banner image" />';
}

?>