Give Your Site Some Season

Beacon Blog Article

By Beacon News | Published December 27, 2010 | Categories: Cascade CMS

Many websites like to modify their logos or layout to suit the holidays or an event. Google's homepage often features a modification to their logo relevant to the date. This can easily be done without the need to manage your images and stylesheets using PHP/ASP or Javascript. A script such as this determines to ouput between:

standard
Holiday

-And-

beacon_xmas.png
Standard

This is an attractive feature for e-commerce websites to highlight holiday products and content to visitors. Here are three working flavors of code to display a pre-made set of holiday images, which only requires to keep the images named respectively and that the directory structure correlate with the code. These can be changed by editing the "file" and "location" variables used below and adding additional else if statements.

PHP

        $month = date("F");
	$location = "/images/";
	if($month == "December"){
		$file = "logo-christmas.png";
	//Add additional else if statements for other occasions.
	}else{
		$file = "logo.png";
	}
	echo "<img src=\"".$location.$file."\" />";

ASP

	Dim Month
	Month = DatePart("m", Date())
	Dim Location
	Location = "/images/"
	If StrComp(Month,"December",1) = 1 Then
		Dim File
		File = "logo-christmas.png"
	'Add additional else if statements for other occasions.
	Else
		Dim File
		File = "logo.png"
	End If
        Response.write("<img src='" & location & file & "' />");

Javascript

	var month = getMonth();
	var location = "/images/";
	if(month=="December"){
		var file = "logo-christmas.png";
		document.write("<img src='"+location+file+"' />");
	//Add additional else if statements for other occasions.
	}else{
		file = "logo.png";
	}
	document.write ("<img src='"+location+file+"' />");

Let's get to work!

Contact Us