|
#1
|
||||
|
||||
|
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'];
}
insert before if ($cfgrow['markdown'] == 'T') Code:
if (!$_SESSION["template"]) {
$_SESSION["template"]=$cfgrow['template'];
}
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);
?>
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 |
|
#2
|
||||
|
||||
|
Nice, but I feel this can be done without hacking the core files. Let alone renaming a config variable.
Why don't you just set the $cfgrow variable to the session variable? That is one way of not renaming stuff in the index.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
|
|
#3
|
||||
|
||||
|
I would be great if someone created an addon like this, especially for template designers as all traffic could go to one actual used blog rather than demo sites.
|
|
#4
|
||||
|
||||
|
this will be nice for addon creator... cool stuff
|
|
#5
|
|||
|
|||
|
Hell yeah - I'm gonna use this !!
Does this work on pp 1.7.1? ![]() LE. I tried and it's working. I'm going to do some playin' around with it.. ![]() LLE. How can I use this hack with link to each template I want instead of drop-list? |
|
#6
|
||||
|
||||
|
I just did the hack and it is working smootly.... wow
|
|
#7
|
||||
|
||||
|
You can put the following code after session_start(); (instead of what was posted earlier) and it will allow you to specify the template in a link to your pixelpost site:
Code:
if ($_POST['newtemplate']) {
$_SESSION["template"]=$_POST['newtemplate'];
} else if ($_GET['newtemplate']) {
$_SESSION["template"]=$_GET['newtemplate'];
}
so they you can go like this: http://www.yoursitehere.com/?newtemp...ameoftemplate1 http://www.yoursitehere.com/?newtemp...ameoftemplate2 http://www.yoursitehere.com/?newtemp...ameoftemplate3 |
|
#8
|
||||
|
||||
|
I would watch out for such insecure code:
PHP Code:
PHP Code:
|
|
#9
|
||||
|
||||
|
I can create an addon but it would still require a hack to index.php
If anyone is interested I'll throw something together
__________________
Pixelpost Documentation | Visual Pixels | My Addons | Transition Bottlerocket Fund |
|
#10
|
|||
|
|||
|
I would love a good addon for this!
|
| Post Reply |
| Thread Tools | |
|
|