Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #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
  #2  
Old 08-20-2007, 05:55 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
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
Reply With Quote
  #3  
Old 02-08-2008, 08:00 PM
Scarabaeus's Avatar
Scarabaeus Offline
pixelpost guru
 
Join Date: Dec 2007
Location: England
Posts: 139
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.
__________________

Reply With Quote
  #4  
Old 02-08-2008, 09:41 PM
fredxeric's Avatar
fredxeric Offline
pixelpost guru
 
Join Date: Sep 2006
Location: Montréal, Québec, Canada
Posts: 407
Send a message via AIM to fredxeric Send a message via MSN to fredxeric
this will be nice for addon creator... cool stuff
Reply With Quote
  #5  
Old 02-09-2008, 08:44 AM
xact Offline
pp regular
 
Join Date: Oct 2007
Posts: 46
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?
Reply With Quote
  #6  
Old 02-18-2008, 06:35 PM
fredxeric's Avatar
fredxeric Offline
pixelpost guru
 
Join Date: Sep 2006
Location: Montréal, Québec, Canada
Posts: 407
Send a message via AIM to fredxeric Send a message via MSN to fredxeric
I just did the hack and it is working smootly.... wow
Reply With Quote
  #7  
Old 02-19-2008, 07:03 PM
kevincrafts's Avatar
kevincrafts Offline
pixelpost guru
 
Join Date: Jul 2007
Location: Colorado
Posts: 434
Lightbulb

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
__________________
Kevin | Light & Dark Photoblog

Reply With Quote
  #8  
Old 02-20-2008, 01:57 PM
GeoS's Avatar
GeoS+ Offline
Team Pixelpost
 
Join Date: Apr 2005
Location: Warsaw, Poland
Posts: 3,613
Send a message via ICQ to GeoS Send a message via Skype™ to GeoS
Exclamation Security stuff

I would watch out for such insecure code:
PHP Code:
if ($_POST['newtemplate']) {
$_SESSION["template"]=$_POST['newtemplate'];
} else if (
$_GET['newtemplate'])  {
$_SESSION["template"]=$_GET['newtemplate'];

I would do that like this:
PHP Code:
if ($_POST['newtemplate']) {
$_SESSION["template"]=$_POST['newtemplate'];
} else if (
$_GET['newtemplate'])  {
$_SESSION["template"]=$_GET['newtemplate'];
}

if(!
is_dir("templates/".$_SESSION["template"])) $_SESSION["template"]=$cfgrow['template']; 
__________________
photoblog | portfolio | addons | Donate
Reply With Quote
  #9  
Old 02-20-2008, 02:23 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
I can create an addon but it would still require a hack to index.php

If anyone is interested I'll throw something together
Reply With Quote
  #10  
Old 02-20-2008, 02:42 PM
EcoSee Offline
pp veteran
 
Join Date: Nov 2007
Posts: 63
Exclamation I Would Love This Addon

I would love a good addon for this!
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 09:37 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs