Members: 10,140
Threads: 38,830
Posts: 159,367
Online: 23

Newest Member: Xoote


Old 01.09.2005, 19:32   #1
webGóbé
Baby Mamber
 
Join Date: Dec 2004
Posts: 5
webGóbé is on a distinguished road
Default Automatically alternate templates

Hi! I need to automatically change the default template on given criteria (like hour of the day, or day of the week, for example I have a blue theme for monday, and a pink one for friday ) Any ideea how can I do this? The cron job is out of question, unfortunately...
webGóbé is offline   Reply With Quote
Sponsored Links
Old 15.09.2005, 22:05   #2
designveteran
Mamber
 
Join Date: Nov 2004
Location: Arizona, US
Posts: 105
designveteran is on a distinguished road
Default Re: Automatically alternate templates

This is one way to do it...


1. Paste this code into your editor then name the file weekday.php
Code:
<? 

function switch_template_by_weekday(){
$date = getdate(); 
$dayofweek = $date['weekday']; 

 switch($dayofweek)
   {
       	case "Monday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Mondaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
      
	  	case "Tuesday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Tuesdaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
		
		case "Wednesday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Wednesdaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
		
		case "Thursday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Thursdaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
		
		case "Friday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Fridaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
		
		case "Saturday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Saturdaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
		
		case "Sunday";
       	echo "<SCRIPT language=\"JavaScript\">
		<!--
		window.location=\"http://someplace.com?mos_change_template=Sundaytemplatename\";
		//-->
		</SCRIPT>";
       	break;
   }

}

	
?>

2. Edit weekday.php, changing the site path and template name in each switch statement. Upload the file to the root directory of the mambo installation (same place configuration.php is).

3. Open up Administrator, Template Manager, select a template, then click on "Edit HTML" Add the following code to each of your templates:


Code:
<?php include ("weekday.php"); ?>

switch_template_by_weekday();
Put the code right after these tags at the top of the <head> tag:

Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


Let me know if it works for you. Post a link when you get done because I'd be interested to see how it turns out.
designveteran is offline   Reply With Quote
Old 01.11.2005, 21:44   #3
Darkstar3d
Guest
 
Posts: n/a
Default Re: Automatically alternate templates

I am giving this a whirl later. The only thing that I don't understand is the window location line. Say if my mambo is running under www.mysite.com/mambo does that mean that the line should be (using solar flare for instance)

window.location=\"http://www.mysite.com/mambo?mos_change_template=/templates/rhuk_solarflare_ii\";

Just wondering if my logic is flawed because I also think that the weekday.php file as written will continually call itself, therefore never actually finishing the page load. Just my 2¢. Which I will test in an hour or so.
  Reply With Quote
Old 01.11.2005, 21:51   #4
Darkstar3d
Guest
 
Posts: n/a
Default Re: Automatically alternate templates

Just gave that javascript line a twirl on the intranet. As I suspected, the page never loads, although it does so progress in the bar at the bottom for a bit.

Perhaps you have a default template, with the line in it. And it calls the other templates which don't. That should eliminate the loop
  Reply With Quote
Old 02.11.2005, 07:24   #5
designveteran
Mamber
 
Join Date: Nov 2004
Location: Arizona, US
Posts: 105
designveteran is on a distinguished road
Default Re: Automatically alternate templates

Are you trying to use it with Joomla?

If so, you need to change the command to jos_change_template
designveteran is offline   Reply With Quote
Old 02.11.2005, 07:32   #6
Darkstar3d
Guest
 
Posts: n/a
Default Re: Automatically alternate templates

No, haven't fired up Joomla yet. Got it working with m4.5.2 but had to publish the template changer. I used one template to call the others. If you put the code in each template, they never load, just a constant request for the page, over and over.

This is running only at my test server so can't show it to you. I just changed your script to change by the hour. And it works. If you already have the template loaded when it changes, you don't get them, it keeps the current template.

I am sure that with some more hacking on it, can get that running too. But, got to get up for work in 4 hours!
  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Erstellen von CSS basierten Templates für Mambo musicones Templates 15 28.11.2005 22:34
Switching templates automatically ? bat Mambo 4.5.1 General Talk 2 10.04.2005 19:42
Switching templates automatically ? bat Template Discussions 0 09.04.2005 19:25
GPL/GNU licenced templates Simbad Template Discussions 4 01.08.2004 21:20


All times are GMT +2. The time now is 23:12.

Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.