Post by veganprovolone » Fri Aug 14, 2009 4:28 am

hello,
i would like to show in the home the product description and the manufacturer. Any help?
thanks!


Posts

Joined
Fri Aug 14, 2009 4:26 am

Post by SubCon » Fri Aug 14, 2009 9:00 am

LOL, I've been just doing that :)
So basically you need to edit 2 files:
home.php in catalog\controller\common
home.tpl in the catalog\view\theme\default\template\common

home.php:
find line 46 or so

Code: Select all

$this->data['products'][] = array(
under it there is:
'name' => $result['name'],
under it add line:

Code: Select all

 'description' => $result['description'],
pay attention to the comma at the end.

home.tpl:
in the html where you want to put the description you add:

Code: Select all

<?php echo $products[$j]['description'];?>
----------------------------------------------
Now I have a problem with this, so maybe someone can help:
the description shows the html tags, have no idea why.. also "strip_tags" does not have any effect.
Thanks

Newbie

Posts

Joined
Thu Aug 13, 2009 6:10 am

Post by bthirsk » Sat Aug 15, 2009 11:10 pm

Try

Code: Select all

<?php echo html_entity_decode($products[$j]['description']);?>

Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by SubCon » Sun Aug 16, 2009 1:20 am

Works like a charm :) thanks man!
Maybe you could explain it a bit?

Newbie

Posts

Joined
Thu Aug 13, 2009 6:10 am

Post by bthirsk » Sun Aug 16, 2009 2:51 am

When description is saved, special characters are escaped.
You just need to convert back to characters you need in you display.

You can check out the manual on php special character handling as well as mysql have some docs

Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by SubCon » Sun Aug 16, 2009 3:21 am

thanks a lot man, got it :)

Newbie

Posts

Joined
Thu Aug 13, 2009 6:10 am

Post by wilmaogando » Tue Aug 18, 2009 9:17 am

Hi, I see this post really helpfull, but what about the manufacturer, can you post what to change to add the manufacturer down the product name in home??

Thanks,

Wilma

Wilma
(Don't speak english)


New member

Posts

Joined
Fri Jul 24, 2009 12:15 am
Location - Dominican Republic

Post by wilmaogando » Tue Aug 18, 2009 11:00 am

Hello!

I found my answer trying antrying, so I post it here maybe can help somebody else.

1) Modify this PHP files:

catalog/controller/product/category.php
catalog/controller/product/manufacturer.php
catalog/controller/product/search.php
catalog/controller/product/special.php

After this:

$this->data['products'][] = array(
'name' => $result['name'],


Add this:

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


2) Modify this TPL files:

catalog/view/theme/default/template/product/category.tpl
catalog/view/theme/default/template/product/manufacturer.tpl
catalog/view/theme/default/template/product/search.tpl
catalog/view/theme/default/template/product/special.tpl

After this:

<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />


Add this:

<span style="color: #666; font-size: 11px;"><?php echo $products[$j]['manufacturer']; ?></span><br>


ERROR NOTE: I just couldn't do it in home.php and home.tpl, it gave me an error, so I don't have in my index, just in other pages. If some one solve this error please post it. The error message I received is:
Notice: Undefined index: manufacturer in /home/wilma/public_html/waohzone.com/catalog/controller/common/home.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at /home/wilma/public_html/waohzone.com/catalog/controller/common/home.php:47) in /home/wilma/public_html/waohzone.com/system/library/response.php on line 65

Wilma

Wilma
(Don't speak english)


New member

Posts

Joined
Fri Jul 24, 2009 12:15 am
Location - Dominican Republic

Post by vivaknievel » Fri Mar 12, 2010 11:21 am

Wilma...

If this will help you... I was able to get the manufacturer to show up on the Home page by doing the following:

1. In home.tpl (opencart/catalog/view/theme/default/template/common/home.tpl), find:

Code: Select all

<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
and then place this before OR after (whichever your prefer):

Code: Select all

<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['manufacturer']; ?></span><br />
2. In home.php (opencart/catalog/controller/common/home.php), find

Code: Select all

'model'   => $result['model'],
and place this before OR after (whichever you prefer):

Code: Select all

'model'   => $result['manufacturer'],
(make sure to include the comma (,) at the end of the line).


======================

Note: I thought about what would happen if the field was left blank, and tried to come up with an "if" statement, but it did not work. I don't desperately need that feature, but I'm putting the code I tried here, in case someone wants to use it as a starting point. I had put this in home.tpl, instead of the other working example (the example above works, and will always show whatever is in the manufacturer field, so ignore the following if you're happy with that.)

Code: Select all

       
       <?php if ($manufacturer) { ?>
              <tr>
                <td><b><?php echo $products[$j]['manufacturer']; ?></b></td>
                <td><a href="<?php echo str_replace('&', '&', $products[$j]['href']); ?>"><?php echo $products[$j]['manufacturer']; ?></a></td>
              </tr>
              <?php } ?>
          

Newbie

Posts

Joined
Fri Mar 12, 2010 10:02 am
Who is online

Users browsing this forum: Bing [Bot] and 27 guests