Forums / Addon Sideboxes / template switch addon

template switch addon

Views: 45,477

Results 1 to 20 of 62
4 Jan 2009, 6:40 PM
#2
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: template switch addon

Hi, I installed this and it turned my store to the default theme and it wouldn't let me change it to anything else. The sidebox didn't show up. What did I do wrong?

4 Jan 2009, 7:04 PM
#3
charmedbytina2 avatar

charmedbytina2

Totally Zenned

Join Date:
Mar 2007
Location:
AZ
Posts:
1,890
Plugin Contributions:
0

Re: template switch addon

You need to edit the templates.txt and you need to make sure the sidebox files are added to ALL of your templates.

Tina

4 Jan 2009, 8:01 PM
#4
dranet avatar

dranet

New Zenner

Join Date:
Mar 2008
Posts:
23
Plugin Contributions:
0

Re: template switch addon

Yeah, I did that. I'm still having problems. The box shows up now but it still won't switch between the templates. Oh well, it was worth a try.

28 Apr 2009, 5:06 PM
#5
wulf359 avatar

wulf359

New Zenner

Join Date:
Feb 2008
Posts:
44
Plugin Contributions:
0

Re: template switch addon

Alright, I figured this out....

You have to go in through the admin, select each template, then go into the layout boxes controller and activate teh box in each one of the templates.... real PITA but it does work

http://www.valhalla-computers.com/demo

14 Jun 2009, 9:13 PM
#6
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

This is not working for me. My site is gone. only the body background color of the classic template shows. :(

14 Jun 2009, 9:17 PM
#7
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: template switch addon

mimi78,

Follow the directions ans insure you create and add to the txt file the new templates

Zen-Venom Get Bitten

14 Jun 2009, 9:47 PM
#8
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

This is what I've found out. When I place the init_templates in the overrides folder the site goes blank. Once i remove the file it all goes back.. the sidebox shows but the templates do not change. When I add the name of my template to the text file on the sidebox it shows next to the template that's in there for example viennabloodmytemplate.

this is what i have from the txt:
classicviennabloodcssxajaxmytemplate should these names be separated?

15 Jun 2009, 2:35 AM
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: template switch addon

should these names be separated?
That appears as one name - - How might programmimg tell where one ends and one begins?

One template name per line in templates.txt

classic
cherry_zen
lavender
etc

Zen-Venom Get Bitten

15 Jun 2009, 3:17 PM
#10
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

What is the init_templates when I paste it in the override folder the site goes blank.

16 Jun 2009, 7:24 AM
#11
hugo13 avatar

hugo13

Zen Follower

Join Date:
Apr 2004
Location:
vienna
Posts:
176
Plugin Contributions:
4

Re: template switch addon

mimi78:

What is the init_templates when I paste it in the override folder the site goes blank.

the only difference to the original file, are the lines 38..50```php
/**

  • The actual template directory to use
    /
    $template_dir = 'classic';
    if(isset($_GET['template_switch_id'])){
    zen_setcookie("zctemplate", $_GET['template_switch_id'], time()+(60
    6024365));
    $template_dir = $_GET['template_switch_id'];
    } else {
    if(isset($_COOKIE["zctemplate"])){
    $template_dir = $_COOKIE["zctemplate"];
    zen_setcookie("zctemplate", $_COOKIE["zctemplate"], time()+(606024*365));
    }
    }
remove the closing ```
?>
``` at file-end; maybe there are chars after
16 Jun 2009, 11:55 AM
#12
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

Thanks Hugo for answering. I removed the ?> from the end but the page stays blank.

Here is the entire init_template code.

<?php
/**
 * initialise template system variables
 * see {@link  http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details.
 *
 * Determines current template name for current language, from database<br />
 * Then loads template-specific language file, followed by master/default language file<br />
 * ie: includes/languages/classic/english.php followed by includes/languages/english.php
 *
 * @package initSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: init_templates.php 316 2008-06-06 15:00:05Z hugo13 $
 */
  if (!defined('IS_ADMIN_FLAG')) {
   die('Illegal Access');
  }

/*
 * Determine the active template name
 */
  $template_dir = "";
  $sql = "select template_dir
            from " . TABLE_TEMPLATE_SELECT . "
            where template_language = 0";
  $template_query = $db->Execute($sql);
  $template_dir = $template_query->fields['template_dir'];

  $sql = "select template_dir
            from " . TABLE_TEMPLATE_SELECT . "
            where template_language = '" . $_SESSION['languages_id'] . "'";
  $template_query = $db->Execute($sql);
  if ($template_query->RecordCount() > 0) {
    $template_dir = $template_query->fields['template_dir'];
  }

/**
 * The actual template directory to use
 */           
 $template_dir = 'classic'; 
   if(isset($_GET['template_switch_id'])){
    zen_setcookie("zctemplate", $_GET['template_switch_id'], time()+(60*60*24*365));
    $template_dir = $_GET['template_switch_id'];
  } else {
      if(isset($_COOKIE["zctemplate"])){
        $template_dir = $_COOKIE["zctemplate"];
        zen_setcookie("zctemplate", $_COOKIE["zctemplate"], time()+(60*60*24*365)); 
      }
  }
 
  define('DIR_WS_TEMPLATE', DIR_WS_TEMPLATES . $template_dir . '/');
  // r.l. hook for smarty      
  
  if('Yes' == ACTIVATE_SMARTY){
    $smarty = new Smarty_Template();
  }         
  
/**
 * The actual template images directory to use
 */
  define('DIR_WS_TEMPLATE_IMAGES', DIR_WS_TEMPLATE . 'images/');
/**
 * The actual template icons directory to use
 */
  define('DIR_WS_TEMPLATE_ICONS', DIR_WS_TEMPLATE_IMAGES . 'icons/');

/**
 * Load the appropriate Language files, based on the currently-selected template
 */

  if (file_exists(DIR_WS_LANGUAGES . $template_dir . '/' . $_SESSION['language'] . '.php')) {
    $template_dir_select = $template_dir . '/';
  /**
   * include the template language overrides
   */
      include_once(DIR_WS_LANGUAGES . $template_dir_select . $_SESSION['language'] . '.php');
  } else {
    $template_dir_select = '';
      //  include_once(DIR_WS_LANGUAGES . $template_dir_select . $_SESSION['language'] . '.php');
  }
/**
 * include the template language master (to catch all items not defined in the override file).
 * The intent here is to: load the override version to catch preferencial changes; 
 * then load the original/master version to catch any defines that didn't get set into the override version during upgrades, etc.
 */
// THE FOLLOWING MIGHT NEED TO BE DISABLED DUE TO THE EXISTENCE OF function() DECLARATIONS IN MASTER ENGLISH.PHP FILE
// THE FOLLOWING MAY ALSO SEND NUMEROUS ERRORS IF YOU HAVE ERROR_REPORTING ENABLED, DUE TO REPETITION OF SEVERAL DEFINE STATEMENTS
  include_once(DIR_WS_LANGUAGES .  $_SESSION['language'] . '.php');


/**
 * send the content charset "now" so that all content is impacted by it
 */
  header("Content-Type: text/html; charset=" . CHARSET);

/**
 * include the extra language definitions
 */
  include(DIR_WS_MODULES . 'extra_definitions.php');
16 Jun 2009, 12:32 PM
#14
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

I am using this version zen-cart-v1.3.8-full-fileset-11302007. I'll check this link you gave me, thank you.

16 Jun 2009, 3:11 PM
#15
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

I'm not sure how to run the debug. I installed it on my server and went to my home page, nothing shows on my cache it is set to writable. So I installed it on my pc and this came on the cache folder.
I'm not sure what I am supposed to do once installing the debug.

This came out:

[16-Jun-2009 11:06:53] PHP Warning: require(includes/templates/template_default/common/tpl_header.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in C:\xampp\htdocs\testing\includes\templates\template_default\common\tpl_main_page.php on line 73

[16-Jun-2009 11:06:53] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required 'includes/templates/template_default/common/tpl_header.php' (include_path='.;C:\xampp\php\pear') in C:\xampp\htdocs\testing\includes\templates\template_default\common\tpl_main_page.php on line 73

On my site the default template shows and although all the side boxes are ON they don't show.

http://onwrapcreations.com/shop/

17 Jun 2009, 3:51 AM
#16
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: template switch addon

If you remove the closing ?> from a php file, you are creating a bigger error than you started out with. Never remove those characters, but you can check if there are spaces after them and remove the spaces.

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

17 Jun 2009, 4:14 AM
#17
hugo13 avatar

hugo13

Zen Follower

Join Date:
Apr 2004
Location:
vienna
Posts:
176
Plugin Contributions:
4

Re: template switch addon

do you see the file includes/templates/template_default/common/tpl_header.php
compare your template_default with the downloaded source

afo:

If you remove the closing ?> from a php file, you are creating a bigger error than you started out with. Never remove those characters, but you can check if there are spaces after them and remove the spaces.

Appendix B. Zend Framework Coding Standard for PHP
B.2. PHP File Formatting
B.2.1. General
For files that contain only PHP code, the closing tag ("?>") is never permitted.
It is not required by PHP, and omitting it prevents the accidental injection of trailing white space into the response.== http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html#coding-standard.php-file-formatting.general == Programmers Reference Guide

20 Jun 2009, 10:54 PM
#18
mimi78 avatar

mimi78

New Zenner

Join Date:
Mar 2009
Posts:
78
Plugin Contributions:
0

Re: template switch addon

I don't know why something so simple is not working for me. :( Is there anyone willing to install it for me? I'd pay of course.

21 Jun 2009, 11:50 PM
#19
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: template switch addon

I don't know why something so simple is not working for me.
I am due back LATE tonight Sunday....PM me with your details

Zen-Venom Get Bitten

12 Jul 2009, 11:23 PM
#20
navido avatar

navido

Zen Follower

Join Date:
Sep 2008
Posts:
221
Plugin Contributions:
0

Re: template switch addon

charmedbytina2:

You need to edit the templates.txt and you need to make sure the sidebox files are added to ALL of your templates.

Tina

In which path is this templates.txt file uploaded to?

Thanks