Creating Conditional Link

I’m building a photography website where in each day I’d post a new photo and have an accompanying blog on a separate page for the same day. My links would be structured as such:

For the photos it would be something like
and the blog would be similar

I want a simple menubar header wherein if people were on the photo for, say, March 10th, and they clicked the ‘blog’ link they are taken to the blog for that same day.

Conversely, if they were on an unrelated portion of the site and clicked either the photos or blog link, I would want them to be directed to the most recent entry for either.

Any ideas? I’m a total newbie.

Without knowing how you store information about blog entries and photos I dont know how to help you with taking the user to the latest entry. Do you store blog/photo entry dates in a database? because if so then its really easy.

however the rest I can do:

<?php $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; //checks to see if either of the words "blog" or "photos" are in the url if(strpos($url,"blog")){ //if "blog" is in the url then the word blog is replaced by photos in the url and the link is shown $new_url = str_replace("blog", "photos", $url); echo "Photos"; }else if(strpos($url,"photos")){ $new_url = str_replace("photos", "blog", $url); echo "Blog"; } else { //link to newest photos } ?>


Sponsor our Newsletter | Privacy Policy | Terms of Service