Post by nwdrummer » Thu Nov 13, 2014 1:21 am

Hello All.

I have a question about adding a variable to the Category / Grid view of my site.

First off a little background.

I am using a template. On the product page there is a line of code that produces the model number below the product name. Here is an screen shot and snippet from the product.tpl:
productpage01.jpg

productpage01.jpg (24.4 KiB) Viewed 2651 times

here is the code line:
"<span>Item Number: </span> <?php echo $model; ?><br />"

______________________________________________________________________________________________________

my goal and question
I want to add this exact line to my category / grid view.

I placed this line of code in the category.tpl.
example:

"<?php if ($product['thumb']) { ?>

<div class="image"><a href="<?php echo $product['href']; ?>"><img id="img_<?php echo $product['product_id']; ?>" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>

<span><?php echo $text_model; ?></span> <?php echo $model; ?>

<?php } ?>

<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>

<div class="description"><?php echo $product['description']; ?></div>

<?php if ($product['price']) { ?>"



When I bring up the category list I am getting and error on the page.
Example:
Undefined variable: model in /home/microtrains/public_html/catalog/view/theme/theme167/template/product/category.tpl on line 208


How do I define this variable in category.tpl so that the item number is displayed along with the other product informtion.

Thanks for you help.

nwdrummer

Newbie

Posts

Joined
Wed Nov 12, 2014 8:10 am

Post by uksitebuilder » Thu Nov 13, 2014 7:52 am

The variable needs to be defined in the controller so the template can use it.

edit: catalog/controller/product/category.php

find

Code: Select all

'product_id'  => $result['product_id'],
Add after

Code: Select all

'model'  => $result['model'],

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by nwdrummer » Thu Mar 26, 2015 2:19 am

Thanks for your help.. This worked perfectly. Sorry for taking so long to come back and thank you.. the project ended up getting put on hold for a few months. O0

Newbie

Posts

Joined
Wed Nov 12, 2014 8:10 am
Who is online

Users browsing this forum: No registered users and 4 guests