Author Topic: [FREE] fjSnippet #1 - Template Selector v1.1  (Read 1812 times)

0 Members and 1 Guest are viewing this topic.

  • Business Owner
  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 439
  • Karma: +45/-39
  • Lets Work Together
  • Referrals: 5
    • Revenue Sharing Program
[FREE] fjSnippet #1 - Template Selector v1.1
« on: February 06, 2013, 01:52:27 PM »
The following snippet is an easy way to allow your site visitor to select a template from a drop down list. This means you do not have to have several copies of the script just to show off your template design work. Plus you only have to manage one database. The code can easily be modified to achieve more functionality.

You can view this fjSnippet in action at http://modelptc.com

Add the following line where you want your template selector. This would be included on say each of the home.php file for your templates.
Code: [Select]
<?php include("templates/template_selector.php"); ?>

Create the file called templates/template_selector.php and add the following code to it.
Code: [Select]
<div align="center">
<form>
<span style="font-weight: bold; font-style: normal; text-decoration: none; font-size: 12pt; color: #FF0000;">View this site using template:</span>
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Choose a template</option>
<option value="templates/switch_template.php?t=default_fj">408FJ Default</option>
<option value="templates/switch_template.php?t=fjrowbl000">BlueRow000</option>
<option value="templates/switch_template.php?t=fjrowbl001">BlueRow001</option>
<option value="templates/switch_template.php?t=fjrowgr000">GreenRow000</option>
<option value="templates/switch_template.php?t=fjrowgr001">GreenRow001</option>
<option value="templates/switch_template.php?t=fjrowpu000">PurpleRow000</option>
<option value="templates/switch_template.php?t=fjrowpu001">PurpleRow001</option>
<option value="templates/switch_template.php?t=default">IWS Default</option>
</select>
</form>
You can get one of the above templates for free. Check <a href="http://aurora-script.info">aurora-script.info</a> for details.
</div>

Create the file called templates/switch_template.php and add the following code to it.
Code: [Select]

<?

$template = $_GET['t'];
include("../includes/settings.php");

if (($template<>"default_fj") &&
($template<>"default") &&
($template<>"fjrowbl000") &&
($template<>"fjrowbl001") &&
($template<>"fjrowgr000") &&
($template<>"fjrowgr001") &&
($template<>"fjrowpu000") &&
($template<>"fjrowpu001") &&
($template<>"default_fj02") &&
($template<>"dsflipcashads")) {
header("Location: ../index.php");
exit;
}

function updatesettings($settings) {
$newfile="<?\n//**"."VS*"."*//$setting[settings]//**"."VE"."**//\n\$settings = array(\n";
foreach ($settings as $title => $setting) {
$newfile.="\"$title\"=>\"$setting\",\n";
}
$newfile.=");\n?>";

$input="../includes/settings.php";
$fpwrite = fopen($input, "w+");
fputs($fpwrite, $newfile);
}


$settings["template"] = $template;
updatesettings($settings);

header("Location: ../index.php");


?>

Create the corresponding folders for your templates, making sure you place the folders in the correct location and that the name matches the drop down list values.

Note this version means that any visitor can switch the current template and it is not locked to a visitor or registered member. A visitor/registered member preference can be added and there are other possibilities for expanding this code usage.

Edit: February 06, 2013, 05:57:56 AM
Just realized this topic should likely be in .....
http://www.talkptc.com/index.php?board=97.0
« Last Edit: February 21, 2013, 11:29:59 AM by fjworld »



  • Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
  • Karma: +0/-0
  • Referrals: 0
Re: [FREE] fjSnippet - Template Selector v1.0
« Reply #1 on: February 19, 2013, 02:04:29 AM »
would this work with AuroraGPT or just fj?

  • Business Owner
  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 439
  • Karma: +45/-39
  • Lets Work Together
  • Referrals: 5
    • Revenue Sharing Program
Re: [FREE] fjSnippet - Template Selector v1.0
« Reply #2 on: February 19, 2013, 02:27:56 AM »
would this work with AuroraGPT or just fj?

Works on any Aurora scripts.

  • Business Owner
  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 439
  • Karma: +45/-39
  • Lets Work Together
  • Referrals: 5
    • Revenue Sharing Program
Re: [FREE] fjSnippet #1 - Template Selector v1.1
« Reply #3 on: February 21, 2013, 11:33:13 AM »
I added a check that would only allow a template from the selection list. This way the site will not error on an invalid url if someone tried to avoid using the template selector to access a blank template or an invalid template name.

 

advertise here