User Tools

Site Tools


tutorials:design_adv:template_set_loading

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:design_adv:template_set_loading [2009/04/07 20:53]
jonyo fixed url example
tutorials:design_adv:template_set_loading [2014/09/25 16:55] (current)
Line 1: Line 1:
 +{{indexmenu_n>40}}
 ====== Template Set Loading ====== ====== Template Set Loading ======
  
-Are you creating your own custom template design, but **don't want everyone to see the changes** until you are finished?  Do you want certain people to be able to view the site using one template setwhile others use another?  Do you want to make it use a certain template set based on some other criteria?+<tip c w>**Warning:**  This is an **advanced** tutorialinvolving making changes to **PHP files**.
  
-What the tutorial specifically doesis walk you through the steps to set it up so that it will "load" a specific template set, if you go to a //special URL// It can be used by developers as a starting point for loading specific template set(s) based on some criteria, sort of as a "hello worldexample.+Changes made using this tutorial can be undone using any of the pages in the admin panel under **Design > ** admin menu, so be sure to keep a "localcopy of the customized file to re-upload.
  
-**Requires Geo 4.0.0**+Before attempting to make changes as described here, be sure you have a **firm grasp of [[tutorials/design/start|the basics]]**, as everything described here builds on top of that. 
 + 
 +Remember, support for PHP customizations as described in this tutorial are outside the scope of the support we offer for Geo support Geo Support can try to help you with the //how// and //where// for editing PHP files, but they cannot make changes for you or try to troubleshoot problems related to customized PHP files.</tip> 
 + 
 +Are you creating your own custom template design, but **don't want everyone to see the changes** until you are finished?  Do you want certain people to be able to view the site using one template set, while others use another?  Do you want to make it use a certain template set based on some other criteria?
  
-<tip c n>**Note:** This tutorial instructs on how to allow site to use different template sets based on certain criteria.  For more info on how to actually create and use your own custom template setssee the other tutorials in this section of the user manual.+What the tutorial specifically does, is walk you through the steps to set it up so that it will "load" specific template set, if you go to a //special URL// It can also be used by developers as a starting point for loading specific template set(s) based on some criteria, sort of as a "hello world" example.
  
-These instructions can be used "in place of" or "in addition to" the steps from other tutorials that instruct you to click the **Use Set** button to start using a custom template design.</tip>+<tip c n>**Note:** This tutorial instructs on how to allow a site to use different template sets based on certain criteria.  This is **not needed** to simply change what template set is used normally, for that just change what template set(s) are marked as active in the admin at [[/admin_menu/design/template_sets/start|Design > Template Sets]].  For more info on how to actually create and use your own custom template sets, see the [[tutorials/design/start|design basics]] tutorials.</tip>
  
 This tutorial will walk you through the steps to set up your site, so that someone can view the site using specific custom template set just by viewing a special URL. This tutorial will walk you through the steps to set up your site, so that someone can view the site using specific custom template set just by viewing a special URL.
Line 18: Line 23:
  
 **Instructions** **Instructions**
-  - Turn off Geo cache, if currently turned on, in your admin at **Site Setup > Cache**. < +  - Turn off Geo cache, if currently turned on, in your admin at **Site Setup > Cache**.((Be sure to keep the cache turned OFF for as long as you are viewing the site with an alternate template set.  Otherwise it will cache your alternate template set any time you view the site using it, so that "normal" users will end up seeing the alternate template set!)) 
-  - In your admin, at **Templates > Template System**, ensure that the template set(s) that you want to have loaded "by default" are used.  That is, the template set you want to be used when a visitor views the website for the first time. <+  - In your admin, at **Design > Template Sets**, ensure that the template set(s) that you want to have active "by default" are used.  That is, the template set you want to be used when a visitor views the website for the first time. <
   - For the purpose of this tutorial, we will assume your "main" template set is **my_templates** and the "special" template set is "new_design" In the rest of the instructions, it uses "new_design", just change that to be whatever you have named the folder for your template set, it will be the same as what is listed under "template sets not used" in the admin. <   - For the purpose of this tutorial, we will assume your "main" template set is **my_templates** and the "special" template set is "new_design" In the rest of the instructions, it uses "new_design", just change that to be whatever you have named the folder for your template set, it will be the same as what is listed under "template sets not used" in the admin. <
-  - Download and open the file **geo_templates/t_sets.php** ((If you do not see that file on your site, in your admin click "Use Set" next to one of your template sets, then click "Reset Sets", so that the Template System will generate the file for you with no template sets loaded.)).  The file will look something like this:+  - Download and open the file **geo_templates/t_sets.php** ((If you do not see that file on your site, in your admin at **Design > Template Sets** just click save and it will create the file.)).  The file will look something like this:
 <code php> <code php>
 <?php <?php
Line 30: Line 35:
 ## if you want. ## if you want.
 ##  ## 
-## Generated: Apr  72009 14:39:53+## Generated: Oct  52010 17:07:16
 ########################################### ###########################################
  
Line 42: Line 47:
  * NOTE: Default template set is always added by system as the last template set  * NOTE: Default template set is always added by system as the last template set
   to load.  You do not need to add the default tempalte set here.   to load.  You do not need to add the default tempalte set here.
 + 
 + * If you do not wish manual changes to be overwritten next time admin makes a
 + * change, be sure to put them in the "custom section" below.
  */  */
- + 
 +if (!defined('IN_ADMIN')) { 
 +# [CUSTOM SECTION] # 
 +//Anything manually added to this section will be left intact even if changes 
 +//are made in the admin panel. 
 + 
 +//BOO! 
 + 
 +# [/CUSTOM SECTION] # 
 +
 geoTemplate::addTemplateSet('my_templates'); geoTemplate::addTemplateSet('my_templates');
 </code>  </code> 
-If you are only using the default template set, that last line will be replaced by a //PHP Comment// stating that there are no template sets.  That is normal.+If you are still only using the default template set, that last line will be replaced by a //PHP Comment// stating that there are no template sets.  That is normal, however this setup is not common on "live" sites since most sites will need to have custom template set to make changes in.
 < <
-  - Add the following code after the "*/" and before the next line that has text on it:+  - Add the following code between the **# [CUSTOM SECTION] #** and **# [/CUSTOM SECTION] #** lines (anything added between these lines will NOT be removed when changes are made in the admin panel):
 <code php> <code php>
 ##########  START Modification - Use special template set if they use special URL  ############ ##########  START Modification - Use special template set if they use special URL  ############
Line 58: Line 76:
  //set a cookie to remember it, but make the cookie only last as long as the  //set a cookie to remember it, but make the cookie only last as long as the
  //browser session  //browser session
- set_cookie('use_template_set',$_GET['use_template_set'],0,'/');+ setcookie('use_template_set',$_GET['use_template_set'],0,'/');
  //set cookie global so it works for this page load  //set cookie global so it works for this page load
  $_COOKIE['use_template_set'] = $_GET['use_template_set'];  $_COOKIE['use_template_set'] = $_GET['use_template_set'];
Line 77: Line 95:
 ## if you want. ## if you want.
 ##  ## 
-## Generated: Apr  72009 14:39:53+## Generated: Oct  52010 17:07:16
 ########################################### ###########################################
  
Line 89: Line 107:
  * NOTE: Default template set is always added by system as the last template set  * NOTE: Default template set is always added by system as the last template set
   to load.  You do not need to add the default tempalte set here.   to load.  You do not need to add the default tempalte set here.
 + 
 + * If you do not wish manual changes to be overwritten next time admin makes a
 + * change, be sure to put them in the "custom section" below.
  */  */
 +
 +if (!defined('IN_ADMIN')) {
 +# [CUSTOM SECTION] #
 +//Anything manually added to this section will be left intact even if changes
 +//are made in the admin panel.
  
 ##########  START Modification - Use special template set if they use special URL  ############ ##########  START Modification - Use special template set if they use special URL  ############
Line 99: Line 125:
  //set a cookie to remember it, but make the cookie only last as long as the  //set a cookie to remember it, but make the cookie only last as long as the
  //browser session  //browser session
- set_cookie('use_template_set',$_GET['use_template_set'],0,'/');+ setcookie('use_template_set',$_GET['use_template_set'],0,'/');
  //set cookie global so it works for this page load  //set cookie global so it works for this page load
  $_COOKIE['use_template_set'] = $_GET['use_template_set'];  $_COOKIE['use_template_set'] = $_GET['use_template_set'];
Line 108: Line 134:
 } }
 ##########  END Modification ############ ##########  END Modification ############
 +
 +# [/CUSTOM SECTION] #
 +}
  
 geoTemplate::addTemplateSet('my_templates'); geoTemplate::addTemplateSet('my_templates');
Line 127: Line 156:
 Below are a few tips: Below are a few tips:
   * If you are afraid that someone you do not want to see the new design, might guess the **special URL**, and want to make it harder for them to figure out:  You can change that code to be whatever you want in the **t_sets.php** file.  You would then use a different URL based on what you changed the //code// to be. <   * If you are afraid that someone you do not want to see the new design, might guess the **special URL**, and want to make it harder for them to figure out:  You can change that code to be whatever you want in the **t_sets.php** file.  You would then use a different URL based on what you changed the //code// to be. <
-  * You don't have to name the template set "new_design", it can be whatever you want it to be.  In the instructions above, you would substitute your own template set name wherever you saw "new_design".+  * You don't have to name the template set "new_design", it can be whatever you want it to be.  In the instructions above, you would substitute your own template set name wherever you saw "new_design"
 +  * Remember to keep your changes to be located **after** the line: <code php># [CUSTOM SECTION] #</code> and **Before** the line: <code php># [/CUSTOM SECTION] #</code>  If you do it that way, when changes are made in the admin panel, you custom code **will be left intact**.  Note that this functionality was **Added in 5.1.1**, if you have a previous version you will need to update to use this functionality. < 
 +  * If you do not see the lines noted in the above note, and you are using at least version **5.1.1**, in your admin panel at **Design > Template Sets** make a change to what template sets are active and save changes, then change the settings back and save changes again.  That will re-create the **t_sets.php** file with the above section added. <
  
 **Tips for PHP Developers:** (these require a little more "do it yourself PHP code") **Tips for PHP Developers:** (these require a little more "do it yourself PHP code")
Line 145: Line 176:
 }</code> }</code>
 < <
-  * When working with //user input//((This goes without saying, but...)), remember to take security into account.<+  * When working with //user input//((This goes without saying, but...)), remember to **take security precautions** to ensure the user input is //cleaned// and is not used in a way that could be abused.<
  
  
tutorials/design_adv/template_set_loading.1239137599.txt.gz · Last modified: 2014/09/25 16:55 (external edit)