View Single Post
  #1  
Old 08-10-2007, 07:32 AM
werksmannschaft's Avatar
werksmannschaft Offline
forum loafer
 
Join Date: Aug 2007
Location: germany
Posts: 2
hack: template-switcher PP V1.6

hi,

the last days i created an ADDON to switch between templates (not styles within a template)

if someone else did this before, just forget it ;-)

to made this work i hacked the index.php in the root directory:

1. Step:
search $cfgrow['template'] and replace with $_SESSION["template"]

2. Step:
insert after the session_start();
Code:
if ($_POST['newtemplate']) {
$_SESSION["template"]=$_POST['newtemplate'];
}
3. step:
insert before if ($cfgrow['markdown'] == 'T')
Code:
if (!$_SESSION["template"]) {
$_SESSION["template"]=$cfgrow['template'];
}
4.step
create an addon.
i named it style_addon.php in the addon-folder
Code:
<?php
/*
Pixelpost version 1.6
style_addon version 0.11
    Author  : gerd reuter <http://www.werksmannschaft.de>
    free to use an modify, no guarantee

The new tag to use in template-switcher are
<STYLE_ADDON>
*/

$addon_name = "style addon";
$addon_description = "will change template";
$addon_version = "0.1";

$style_action=$REQUEST_URI;

$actstyle=$_SESSION["template"];
$style_addon="";
$style_addon.="
		<div id='styleselect'><form method='post' name='stylechange' action='$style_action' accept-charset='UTF-8'>
		style <select name='newtemplate' onchange='submit();'>
		<option value='".$actstyle."'>".$actstyle."</option>
		";
		// go through template folder
		$temp_dir = "templates";
		if($style_handle = opendir($temp_dir)) {
			while (false !== ($temp_file = readdir($style_handle))) {
				if($temp_file != "." && $temp_file != ".." && $temp_file != "splash_page.html" && $temp_file != "index.html" && $temp_file != $actstyle) {
					$style_addon.= "<option value='$temp_file'>$temp_file</option>";
					}
				}
			closedir($style_handle);
			}
		$style_addon.= "
		</select>
		</form></div>
";

$tpl = str_replace("<STYLE_ADDON>",$style_addon,$tpl);

?>
5. change EVERY of your xxx.html files in your template-folders.
and add the <STYLE_ADDON> wherever you want to your code.

if you like to see a preview visit the photoblog of my son:
http://moritz.pustekuchen.de
__________________
______________
gerd
r'n'r

Last edited by werksmannschaft; 08-10-2007 at 07:39 AM. Reason: correct some words
Reply With Quote