You could use a version of swguy's boilerplate code to evaluate some PHP and substitute its output for a placeholder in the description output.
You could use a version of swguy's boilerplate code to evaluate some PHP and substitute its output for a placeholder in the description output.
Adapted from swguy's boilerplate tips on his site (referenced in http://www.zen-cart.com/forum/showthread.php?t=120888):
/includes/templates/custom/templates/tpl_product_info_display.php
Change
toPHP Code:<!--bof Product description -->
<?php if ($products_description != '') { ?>
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
<?php } ?>
<!--eof Product description -->
PHP Code:<!--bof Product description -->
<?php if ($products_description != '') { ?>
<?php
$php_content = '';//build content to be substituted for PHP_SUB in description
if ($featured_products->RecordCount() > 0) {
for ($i = 0; $i < $featured_products->RecordCount(); $i++) {
$php_content .= '<div class="categoryListBoxContents" style="width:33%;">';
$php_content .= '<a href="' . zen_href_link(FILENAME_DEFAULT, 'main_page=product_info&products_id=' . $featured_products->fields['products_id']) . '">';
$php_content .= zen_get_products_image($featured_products->fields['products_id']);
$php_content .= '</a></div>';
}
}
$products_description = str_replace('PHP_SUB', $php_content, $products_description);
?>
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
<?php echo stripslashes($stripped_products_description); ?></div>
<?php } ?>
<!--eof Product description -->
The above follows from the boilerplate discussion for the product info page; it would be a different file and slightly different code for the category listing page, but the same principle applies.
Thanks for the reply, I am not that great with PHP and got a little confused trying it
/includes/templates/your_template/templates/tpl_index_categories.phpPHP Code:<?php
// **********insert boilerplate code here to substitute in description**********
// categories_description
if ($current_categories_description != '') {
?>
<div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description; ?></div>
<?php } // categories_description
?>
<!-- BOF: Display grid of available sub-categories, if any -->
Last edited by gjh42; 26 Sep 2010 at 08:57 PM.
Better description of method:PHP Code:<?php
// categories_description
if ($current_categories_description != '') {
$php_content = '';//build content to be substituted for PHP_SUB in description
$php_content .= 'whatever code you need to determine the substituted content for this category';
$current_categories_description = str_replace('PHP_SUB', $php_content, $current_categories_description);
?>
<div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description; ?></div>
<?php } // categories_description ?>
This looks really useful but what if I just wanted it to pull the actual content from the database that doesn't have php?
You need some PHP code to run a SQL query or otherwise determine the information that is going to be added. What content do you want to fetch from the db?
wow, i spent at least 6 hours playing around with the coding (should prob start learning PHP) but that worked great.
As always, thanks for the help.