Jump to content

Trouble using if/else on a single index.php file


39Design

Recommended Posts

Hi everyone! Nice to meet/see/read you. :)

 

This is my first post and it will probably be a lame one so apologies. I'm a pretty good frontend designer and I've always struggled to learn PHP and my new job is forcing it on me so I'm happy in a "throw me in the deep end" kinda way.

 

I am really stuck! I have a single page that is using jquery to scroll my content left and right via the menu (example attached). What I am trying to do is when on the homepage, don't show the "main logo". When on any other link, show it.

 

I immediately thought of an if/else statement but realised I don't know what or how exactly to target since everything is on the same page and the URL doesn't change. Could I target the image title that is the only image on the homepage? So, something like:

 

<?PHP

$image_title = 'home';

 

if (XXXXX($image_title)) {

echo "IMAGE";

} else {

echo "NO IMAGE";

}

 

?>

I know that's wrong, I put XXX where I feel like something possibly helpful should go. Heh.  :-\

 

I'm not asking for someone to write code for me, I'm happy to learn but but I would be very grateful if someone could just guide me to what I need to do and off to Google I will go. I haven't been able to find anything that is like: "if image title equals".

 

Hmm... I hope I can do this with PHP.

 

Thanks again,

Linda

 

[attachment deleted by admin]

Link to comment
Share on other sites

This is more of a javascript thing than a PHP one.  jQuery must have some state stored to remember which page it's showing - you can just use this to test and then if neccessary hide the main logo using javascript.

 

PHP finishes executing before the page is shown to the user.  Without getting into AJAX, which is unneccessary in this case, you can't use PHP to change the page without loading a new uri.

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.