If anyone is interested, here is the code I used.
I created a file called changetemplate.php with the following code:
Code: Select all
<?php
$my_host = "your host";
$my_user = "your cms db user";
$my_pass = "your cms db password";
$my_data = "your database name";
$template_id = $_GET["template_id"];
$template_array = array("20", "21", "22");
$my_dbconn = mysql_connect("$my_host", "$my_user", "$my_pass") or die("Could not connect: " . mysql_error());
mysql_select_db("$my_data",$my_dbconn);
if (in_array($template_id, $template_array)) {
mysql_query("UPDATE cms_content SET template_id = '$template_id'");
}
mysql_close ($my_dbconn);
header( 'Location: /index.php' ) ;
?>
You also need to put some links on your page to call the template switcher. I put mine in the templates, either above the header or below the footer using links like:
Code: Select all
<p>
<a href="http://your.domain.com/changetemplate.php?template_id=20">Style 1</a>
<a href="http://your.domain.com/changetemplate.php?template_id=21">Style 2</a>
<a href="http://your.domain.com/changetemplate.php?template_id=22">Style 3</a>
</p>
Nullig