Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    20
    Plugin Contributions
    0

    Default Creating Custom Layouts for Categories

    A store I'm building for a client requires specially tailored category pages. I searched through the forums for a good hour and couldn't find anything about anyone facing a similar issue. So I created something that would do the trick.

    I'll provide code below. The use of this mod is really only pertinent when a client or store owner has a fixed set or very slowly changing set of categories / sub categories that they want to display in a way that is unique from other categories or the default way categories are displayed. For example my client wanted one section to have very large graphical links to sub-categories in one top category and in another category have text links that are mixed with flash. So I came to the conclusion that it would be most easily accomplished by creating static pages that are inserted when the right category is needed as it is far more trouble some to hack at the stylesheet and template files to conditionally render the appropriate template. As I said earlier this is only a useful method if the product categories change slowly or not at all. As each change in category structure requires you to update the template files for each category page you have made.

    If this sounds like something you would be interested in doing here is how you can do it:

    Locate the tpl_index_categories.php file for your template or make one if it already doesnt exist.

    at Line 45 (ver 1.3.7) there will be a " } " Comment this brace out. As we will be inserting more code here to change the behaviour.

    around line 43 there is a "} else {" Below this statement insert the following:

    Code:
    /**
         *
         * Modification that looks up a category define page for the active category
         * If the active category has a define page, and the define page
         * is set to be active.  The system displays that
         * Otherwise it displays the dynamic content from the database.
         * 
         **/
         
         // Select the define page for the Current value of $cPath 
         // Which is always the current category.
        $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', 'define_cat_' . $cPath, 'false');
        
        if( file_exists($define_page) ){ //test to see if there is such a file?
            include($define_page);
        } else { //Proceed as normal and render the dynamic content
    This will look for a file called define_cat_XX.php where XX is the current category/ sub category.

    if this file is found it includes it other wise the page is dynamically drawn as normal.

    to finish off everything there is one more snippet of code. At line 116 of the original file is " } // !EOF " Before this statement insert the following:

    Code:
     } //end while
     } //end load define page.
    This will complete all your braces and everything will be great. If anyone has any questions or needs a completed file let me know and I'll do my best.

  2. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Creating Custom Layouts for Categories

    You should be studying the "Customised Pages by CSS" section (or something like that...)

    You can have specific sections of your store look completely different from others - its all in this Page-Based CSS idea.

    I don't know enough about it, but I do know it's possible...
    20 years a Zencart User

  3. #3
    Join Date
    Dec 2006
    Posts
    20
    Plugin Contributions
    0

    Default Re: Creating Custom Layouts for Categories

    I've already done as much as I could with CSS on those pages. My problem was needing to put very specific content into the pages. For example Flash movies, overly large images on one sub category but not on another. Currently zen cart doesn't allow you to do this (flash movies for sure) but I needed to so I made the above modifications.

  4. #4
    Join Date
    Aug 2004
    Location
    Fountain Hills, AZ
    Posts
    515
    Plugin Contributions
    1

    Default Re: Creating Custom Layouts for Categories

    I'm trying to imagine what you are doing here. It sound interesting. Would you post a link so I could take a peek.

    Thanks

  5. #5
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,821
    Plugin Contributions
    2

    Default Re: Creating Custom Layouts for Categories


 

 

Similar Threads

  1. Creating different layouts for Product listing pages
    By jpietrowiak in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 13 Oct 2011, 09:40 PM
  2. Creating Custom Border Around Categories
    By Karm4 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 15 Aug 2010, 05:49 AM
  3. Different product listing layouts for different categories?
    By kbascombe in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 Apr 2010, 09:36 AM
  4. Creating Custom Fields for Products based on Category
    By Kma1819 in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 12 Feb 2008, 11:51 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