Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Need help to write correct line of code...

Need help to write correct line of code...

Views: 770

Results 1 to 3 of 3
4 Apr 2011, 10:49 PM
#1
alyona avatar

alyona

New Zenner

Join Date:
Feb 2009
Posts:
12
Plugin Contributions:
0

Need help to write correct line of code...

I want to add a line of code into tpl_product_info_display.php
The file has following code:

<?php require($template->get_template_dir('tpl_modules_also_purchased_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_also_purchased_products.php');?>

Based on that code I want to display following:

<?php require($template->get_template_dir('tpl_modules_featured_products2.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products2.php'); ?>

Also I have tpl_modules_featured_products3.php and tpl_modules_featured_products4.php which I also will need to call.

If I will use the call code from above for each file it will show all those three boxes 2, 3, and 4 on the page.

But I need to call them when certain category is displayed.

So I need a line of code which will define in which category the given product is sitting and accordingly will show necessary file (box).

Example:

if (current product displayed is in the category cPath=1) {

<?php require($template->get_template_dir('tpl_modules_featured_products2.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products2.php'); ?>

}

I hope I explained it properly.
Can anyone help? Is it possible?

4 Apr 2011, 11:06 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Need help to write correct line of code...

It sounds like you want to display only one of these boxes, according to the current category (and none of them on other pages?) If that is true, you could do this:```php
switch ($cPath) {
case '1':
require($template->get_template_dir('tpl_modules_featured_products2.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products2.php');
break;
case '7':
require($template->get_template_dir('tpl_modules_featured_products3.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products3.php');
break;
case '35':
require($template->get_template_dir('tpl_modules_featured_products4.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products4.php');
break;
default:
//any default code desired
}

5 Apr 2011, 1:29 AM
#3
alyona avatar

alyona

New Zenner

Join Date:
Feb 2009
Posts:
12
Plugin Contributions:
0

Re: Need help to write correct line of code...

Thank you, thank you,

It works beautifully :D