Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2009
    Posts
    80
    Plugin Contributions
    2

    Default Template overide/switch for one category

    Hi Guys,

    I am trying to create a different index_product_list.tpl for one category.

    The reason for this is I would like to move items/elements around which cannot be achieved through css.

    So far I have done this:

    I have added a switch into /includes/init_includes/init_template.php

    Code:
    switch($_GET['cPath']) { //test for a matching string 
      case "158": // if current cPath is 158 set the appropriate template
        $template_dir = "video"; // directory name of template (includes/templates/video)
      break;
    }
    This works, however every other aspect of the template changes aswell.

    So to get this working correctly I would have to go into every individual folder looking for my overide files, create a copy and rename to video. Along with loading the template and resetting the layout boxes.

    It seems pointless making duplicate files, is there any more elegant way to change one template for one category?

    Kind Regards

    Dave

  2. #2
    Join Date
    Nov 2009
    Posts
    80
    Plugin Contributions
    2

    Default Re: Template overide/switch for one category

    is there some way I could achieve this with a if statement in main_template_vars.php?

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Template overide/switch for one category

    Yes, it will be possible to just call an alternate version of the file for your category. I'll have to take a look at which file will be the appropriate location for the alternate call.

    You might also consider the approach taken by the Column Layout Grid mod, which has code for both the standard "rows" product listing and the "columns" layout, switching to use different parts of the file as appropriate. That keeps all of the modifications in one file. Actually, what you want to do will probably be best served by modifying product_listing.php and tpl_modules_product_listing.php, just as Column Grid does. Download that mod and look at it to see how it works.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Template overide/switch for one category

    Depending on what kind of differences you want in the display, you might also want to edit tpl_index_product_list.php... the exact file(s) to be edited depend on how you want to modify the listing.

    Do you have a mockup of the desired layout for your special category?

  5. #5
    Join Date
    Sep 2011
    Posts
    14
    Plugin Contributions
    0

    Default Re: Template overide/switch for one category

    Quote Originally Posted by gjh42 View Post
    Yes, it will be possible to just call an alternate version of the file for your category. I'll have to take a look at which file will be the appropriate location for the alternate call.
    Did you locate the file where this change should be made? I'm also looking to create a new layout for certain categories.

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Template overide/switch for one category

    That really depends on what kind of changes you want to make. If you want fundamental reorganization of the product listing page, you would want to add alternate sections with switches in /includes/templates/your_template/templates/tpl_index_product_list.php.
    If you want the parts of individual products in the listing to be organized differently, you would want to edit /includes/modules/your_template/product_listing.php and possibly /includes/templates/your_template/templates/tpl_modules_product_listing.php.

    /includes/modules/pages/index/main_template_vars.php calls tpl_index_product_list.php, which calls tpl_modules_product_listing.php, which calls product_listing.php at the very top.

    The file to modify or create an alternate for will depend on what you want to do.

  7. #7
    Join Date
    Sep 2011
    Posts
    14
    Plugin Contributions
    0

    Default Re: Template overide/switch for one category

    @gjh42 - Thanks for that. To prevent post duplication, what I want to do is outlined here: http://www.zen-cart.com/forum/showthread.php?t=185822

  8. #8
    Join Date
    Nov 2009
    Posts
    80
    Plugin Contributions
    2

    Default Re: Template overide/switch for one category

    Gjh42,

    Thanks for the reply, I am taking a look at that module now.

    Kind Regards

 

 

Similar Threads

  1. Urgent - One type of shipping for only one category
    By beyre in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 16 Oct 2009, 05:01 PM
  2. Huh! Template overide - no sideboxes?
    By dcprod in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 6 Jun 2009, 06:51 PM
  3. template overide problem
    By Matt Smith in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 11 Nov 2008, 08:02 AM

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