Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 60
  1. #11
    Join Date
    Jul 2006
    Posts
    31
    Plugin Contributions
    0

    Default Re: Switching templates at run time

    Another way of switching templates at run time could work like this (a tad sketchy, but placing the code as I suggested earlier in includes/init_includes/init_templates.php) - there could be several ways to do this but this is just one:

    Code:
    // template directory/folder name = array of category ids (cPath) that are to use that template
    // also set the template directory names
    $mens = array(1,2,4,5,8);
    $mens['template_dir'] = 'mens';
    $womens = array(3,6,7,9);
    $womens['template_dir'] = 'womens';
    $kids = array(10,11,12);
    $kids['template_dir'] = 'kids';
    
    // put all the templates listed above together in an array
    $templates = array($mens, $womens, $kids);
    
    // find the appropriate template to use
    // loop through all the template dirs
    for($i=0; $i < count($templates); $i++) {
      if($template_dir != '') {
        break;
      }
      // loop through all the category ids (cPath)
      for($i2=0; $i2 < count($templates[$i]); $i2++) {
        // if the current cPath we're looking at matches the cPath that the visitor is browsing, set the current template we're looking at as the template to use
        if($templates[$i][$i2] == $_GET['cPath']) {
          $template_dir = $templates[$i]['template_dir'];
          break;
        }
      }
    }
    Last edited by eccentric; 3 Nov 2006 at 01:59 AM.

  2. #12
    Join Date
    Jul 2006
    Posts
    31
    Plugin Contributions
    0

    Default Re: Switching templates at run time

    Quote Originally Posted by clydejones View Post
    Why not do a stylesheet for the category call it c_4.css
    Where 4 would be the category for "shirts"

    the stylesheet would consist of declarations used only by that category.

    You could change the header_bg image and any thing else to make that page unique.

    The stylesheet would only be called when that category page is displayed.

    doing this saves messing with the core code.
    I guess it depends on the layout/structure of your site and how good you are with CSS. But sometimes you might want a completely different layout for a different category - not just a different banner, different fonts, different background, etc. For this reason I needed to be able to switch entire templates (folders).

  3. #13
    Join Date
    Nov 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Switching templates at run time

    You mention the file

    includes/init_includes/init_templates.php

    as the file that has to be modified.

    Being a great believer in the override system, where would I copy the original file to before I make any modifications?

  4. #14
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Switching templates at run time

    Your override file would go in includes/init_includes/overrides
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  5. #15
    Join Date
    Nov 2006
    Posts
    21
    Plugin Contributions
    0

    Default Re: Switching templates at run time

    A clarification ... just to see if this solution will work for me...

    I have two "categories".

    Category #1 are items that needs to be displayed using one large photo. (displaying them using the standard row-based layout on the category page won't do).

    The idea here is to click on the category "categ_1", then be taken to a page with a large image that is the first product in categ_1. To see the next product in categ_1, click on next (or previous). If you want to purchase the product, you click on the image and are taken to a product page.

    The other type of category (categ_2) contains items that can be displayed in the normal way -- the category page contains 3 or 4 items per row. Click on one of the items and you are taken to a product page.

    So.. the question is, how do I get a different layout for the category page for categ_1 and keep the default layout for the category page for categ_2?

  6. #16
    Join Date
    Jul 2004
    Location
    The Netherlands, Wierden
    Posts
    430
    Plugin Contributions
    0

    Default Re: Switching templates at run time

    Quote Originally Posted by clydejones View Post
    Why not do a stylesheet for the category call it c_4.css
    Where 4 would be the category for "shirts"

    the stylesheet would consist of declarations used only by that category.

    You could change the header_bg image and any thing else to make that page unique.

    The stylesheet would only be called when that category page is displayed.

    doing this saves messing with the core code.
    This works fine, but it is only for that category and not for that category with his sub-categories and products.

    Howe can i set this to al the products and sub-categories?

  7. #17
    Join Date
    Sep 2006
    Location
    Jacksonville, FL
    Posts
    236
    Plugin Contributions
    0

    help question Re: Switching templates at run time

    This does not seem to be working for me....

    Code:
      //change flash header for different categories
      
      if($_GET['cPath']) {
      
      	switch($_GET['cPath']) {
        
        case 1: // Video
        
          $template_dir = "jlawless_video"; // directory name of Men's Clothing template (includes/templates/mens)
        
          break;
        
        case 2: // Software
        
          $template_dir = "jlawless_software"; // directory name of Women's Clothing template (includes/templates/womens)
          
          break;
        
        default: // If none of the above
        
          $template_dir = "default"; // directory name of default template (includes/templates/jlawless)
          
          break;
       
         }
      
      }

    ive copied, renamed my default template and changed out my flash header and nothing seems to be happening. is there something wrong with my code? im thinking i havent specified a cPath.... but im not sure. any help with this would be great!
    John L.
    MultiMedia Designer

  8. #18
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Switching templates at run time

    The code has some problems and may be simply being ignored.

    For the syntax I would recommend using if(isset($_GET['cPath'])), and switch((int)$_GET['cPath']).

    The logic may then be slightly off. Is it your intention to only execute the switch when you are on the index pages and do you have alternative code to set $template_dir when you're not?

    Finally, using integer categories will only work for top level categories. Sub category paths are passed in the GET defined as strings showing the category hierarchy (e.g. "2_19" for subcategory 19 in top category 2) and will break your approach if you use them.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  9. #19
    Join Date
    Sep 2006
    Location
    Jacksonville, FL
    Posts
    236
    Plugin Contributions
    0

    help question Re: Switching templates at run time

    I have a flash header that i would like to switch when a new category is chosen. If someone clicks on video category the video swf starts. I would like it to work with the subcategories of the video category as well... is this possible? Im having probs just getting it to work with the main cat at the moment, so first things first i guess.
    John L.
    MultiMedia Designer

  10. #20
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Switching templates at run time

    If it's only the flash header that changes, why switch the whole template? It would be easier to put the switch in where you have embedded the call to the flash file.

    You haven't said whether you want different flash files for the subcategories or simply for the subcategories to also display the file appropriate to their parent category (ironically the later is marginally more difficult!)
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 
Page 2 of 6 FirstFirst 1234 ... LastLast

Similar Threads

  1. switching templates
    By RichardH in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 23 Jul 2008, 10:36 PM
  2. Switching php version in WAMP5 causes install to run
    By GreggShort in forum Installing on a Windows Server
    Replies: 2
    Last Post: 27 Jul 2007, 06:06 AM
  3. switching between templates
    By fairview in forum General Questions
    Replies: 4
    Last Post: 9 Apr 2007, 02:44 PM
  4. switching templates
    By onakat in forum Customization from the Admin
    Replies: 6
    Last Post: 3 Apr 2007, 10:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR