Jump to content

if statement with url


ruud2000

Recommended Posts

Hi,

I have a question, I try to show a different picture  my left table depending on the url, I mean something like this:

 

<?php if  (url=="index.php?option=com_content&view=frontpage&Itemid=1")

{

echo ('<img src=\"templates/RBL/images/webmaster.gif\" alt=\"Administrator\" border="0" />');

}

?>

<?php if  (path=="index.php?option=com_content&view=frontpage&Itemid=2")

{

echo ('<img src=\"templates/RBL/images/global.gif\" alt=\"Administrator\" border="0" />');

}

 

But this does'nt work, what can I do?

 

Greetings

Ruud

?>

Link to comment
Share on other sites

I'm assuming you either are using constants or aren't sure how to define the url.....

 

<?php

  function get_image($id) {

    switch($id) {
      case '1':
        $image = 'webmaster.gif';
      break;

      case '2':
        $image = 'global.gif';
      break;
    }
    return $image;
  }

  $id = $_GET['id']; // This would be the value in http://yourdomain.com/index.php?id=123
  $img = 'templates/RBL/images/'.get_image($id);

  echo '<img src="'.$img.'" order="0" />';

?>

 

Possibly something like that....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.