November 18, 201015 yr Hello, I am slowly learning how to do more and more with php and integrating it into my sites. The latest thing I have come up with is to swap the logo on a site depending upon the time of year. 5 logos: a default and then one for Christmas, Easter, valentine and Halloween. It seems to work but I am sure there is a way to make this better. It currently inserts the link into an <img src""/> but all the php is included within the src"" which seems a little untidy! Would I be better to remove this to an external file and have it insert only the relevant link? I am concerned about not only the page looking untidy but also the SEO implications of having all this code at the top of my site. thanks <?php $today = date('Y-m-d'); $xmasOn = '2010-12-01'; $xmasOff = '2011-01-06'; $valentineOn = '2011-02-07'; $valentineOff = '2011-02-21'; $easterOn = '2011-04-17'; //easter sunday - April 24 $easterOff = '2011-05-01'; $halloweenOn = '2011-10-24'; $halloweenOff = '2011-11-06'; if ( ( $today >= $xmasOn ) && ( $today <= $xmasOff ) ) {echo "images/winking_logo_xmas.gif";} elseif ( ( $today >= $valentineOn ) && ( $today <= $valentineOff ) ) {echo "images/winking_logo_valentine.gif";} elseif ( ( $today >= $easterOn ) && ( $today <= $easterOff ) ) {echo "images/winking_logo_easter.gif";} elseif ( ( $today >= $halloweenOn ) && ( $today <= $halloweenOff ) ) {echo "images/winking_logo_halloween.gif";} else {echo "images/winking_logo.gif";} ?>
November 18, 201015 yr If you want it to look neater in your IDE/editor then store the code in an include file and call that. <img src="<?php include ('dynamic_logo.php');?>" /> or store it all at the top of the page and get it to populate a variable instead of echoing the data. <img src="<?=$dynamicLogo?>" /> Either way there are no SEO implications as your web server will parse the PHP and only output the image string.
November 18, 201015 yr Author Ah OK I didn't realise that was the case with SEO implications. The file is already actually a php include file so I might as well leave it where it is! Thanks for the hints. .....still learning :-)
Create an account or sign in to comment