Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / How can I display a customized tpl_product_info_display.php for a certain category

How can I display a customized tpl_product_info_display.php for a certain category

Locked

Views: 1,698

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
13 Oct 2008, 10:31 AM
#1
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

How can I display a customized tpl_product_info_display.php for a certain category

Hi there,

I need to use a customized tpl_product_info_display.php for a certain product category. All the products in that category will share the same modified template. The template will not be used outside that category.

Would I have to set up a dedicated product type or is there an easier way to accomplish this?

Thanks!

Andreas

13 Oct 2008, 12:30 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How can I display a customized tpl_product_info_display.php for a certain category

create your file and save it in your template folder in a folder named for the cat

i.e. if the cat address were like this: /index.php?main_page=index&cPath=3

Then make a folder "cPath_3" (I think this is the correct syntax), and place your custom file there

13 Oct 2008, 1:24 PM
#3
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: How can I display a customized tpl_product_info_display.php for a certain category

Thanks for the quick answer.

At first I was a bit disappointed because the proposed solution doesn't seem to do the trick.

I saved the modified tpl_product_info_display.php into a newly created cPath_1 older like this:
\includes\templates\MYTEMPLATE\templates\cPath_1\tpl_product_info_display.php
but could not get the modified template beeing used this way.

Still your answer proved to be very helpful. I was not aware of the cPath system until now. (just started last week to rebuild my shop based on zen-cart)
I looked it up on the wiki and I am confident that I can now implement the desired behaviour by evaluting the cPath variable within the original template.
Thanks again!

regards

Andreas

13 Oct 2008, 2:13 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How can I display a customized tpl_product_info_display.php for a certain category

I saved the modified tpl_product_info_display.php into a newly created cPath_1 folder
Well, garbage.....try naming it cPath=1 and then try cPath1

This works for those in the common dir like for privacy. checkout etc...

Maybe needs to be a folder inside the templaqtes folder???

13 Oct 2008, 8:33 PM
#5
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: How can I display a customized tpl_product_info_display.php for a certain category

kobra:

Well, garbage.....try naming it cPath=1 and then try cPath1
I tried both and it did not work. Anyway I was able to do everything I wanted by simply evaluating the $cPath variable within the regular template:

(...)
if ($cPath == '1')
// do this
else
// do that
(...)

This is very straightforward and allows any customization from replacing a single standard element to loading an entirely different page layout.

This works for those in the common dir like for privacy. checkout etc...

Interesting. I'll have a look a the code that loads the alternative templates once I have brought my shop into shape.

best regards

Andreas

15 Oct 2008, 10:25 PM
#6
flobster avatar

flobster

New Zenner

Join Date:
Sep 2006
Posts:
76
Plugin Contributions:
1

Re: How can I display a customized tpl_product_info_display.php for a certain category

I wonder if you would be good enough to go through exactly how you acheived this,

I am looking to load a different tpl_index_categories.php for certain categories, the reason for this is a do not want to show the subcategory links in certain categories but i do in others,

I would think i would acheive this in a similar way you have acheived what you are looking for i am just not sure how to go about it,

Any help would be greatly apreciated.

Rob

16 Oct 2008, 6:42 AM
#7
dause avatar

dause

New Zenner

Join Date:
Sep 2008
Posts:
33
Plugin Contributions:
0

Re: How can I display a customized tpl_product_info_display.php for a certain category

flobster:

I wonder if you would be good enough to go through exactly how you acheived this

You are welcome. Here is how you hide the sub categories of a certain category:

  1. Go to your webshop and open the category page you want to modify.
  2. Look at the page url in the browsers address field. It contains a substring 'cPath=X_Y_Z' with X_Y_Z beeing a number or a couple of numbers with _ inbetween (like '1_2_3' for example).
  3. Now copy the file
    \includes\templates\template_default\templates\tpl_index_categories.php
    to
    \includes\templates\MYTEMPLATE\templates\tpl_index_categories.php
    where MYTEMPLATE is the template you are using in your shop
    (skip this step if the file already exists in the MYTEMPLATE\templates directory)
  4. open the copied tpl_index_categories.php file with a text editor and go to the part that handles the display of subcategories. It starts with the comment line:
<!-- BOF: Display grid of available sub-categories, if any -->
  1. Now change this line:
    if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0) {
    to
    if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0 || $cPath == 'X_Y_Z') {
    (replace X_Y_Z with the substring you found in step 2)
  2. save the file and check out if the modification works.
    Note: this will only hide the subcategories on the category page. They will still be displayed in the categories sidebox.

Andreas

23 Oct 2008, 7:48 PM
#8
flobster avatar

flobster

New Zenner

Join Date:
Sep 2006
Posts:
76
Plugin Contributions:
1

Re: How can I display a customized tpl_product_info_display.php for a certain category

Dause,
That works a treat thank you very much, just what i have been looking for

Rob