Forums / Templates, Stylesheets, Page Layout / Creating Custom Layouts for Categories

Creating Custom Layouts for Categories

Locked

Started by fostergross on 6 Mar 2007, 8:14 PM · Views: 1,908

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
6 Mar 2007, 8:14 PM
#1
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

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:

/**
     *
     * 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:

 } //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.

7 Mar 2007, 2:52 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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

8 Mar 2007, 2:40 PM
#3
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

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.

14 Mar 2007, 6:19 AM
#4
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Location:
Fountain Hills, AZ
Posts:
476
Plugin Contributions:
0

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