Page 2 of 3

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 12:35 am
by Qphoria
updated for earlier versions

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 12:41 am
by i2Paq
What would the code be if used only on the product-listing page?

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 1:32 am
by helenmarie
Thank you Q, thats awesome!

i2paq,

I think it would be the same but you enter the code into

catalog/controller/product/category.php

and

catalog/view/theme/default/template/product/category.tpl

but im no coding expert so backup if your gonna try it ;D
Id try it but got to rush out now

Helen

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 3:24 am
by i2Paq
helenmarie wrote:Thank you Q, thats awesome!

i2paq,

I think it would be the same but you enter the code into

catalog/controller/product/category.php

and

catalog/view/theme/default/template/product/category.tpl

but im no coding expert so backup if your gonna try it ;D
Id try it but got to rush out now

Helen
Nope, I'm getting:

Code: Select all

Notice: Undefined index: description in /var/www/vhosts/oc-directory.info/subdomains/oc148/httpdocs/catalog/view/theme/default/template/product/category.tpl  on line 54

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:50 am
by helenmarie
aah yeh same error here too :-\

I dont know then, maybe Q will be able to help?

:)

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 3:22 pm
by i2Paq
helenmarie wrote:aah yeh same error here too :-\

I dont know then, maybe Q will be able to help?

:)
Hopefully... Qphoria, help please? ::)

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 6:34 pm
by JAY6390
You should have

Code: Select all

                        'description'    => preg_replace('/[\r\n\s]+/', ' ', strip_tags(substr(html_entity_decode($result['description']),0,80)))."...",  
after

Code: Select all

                        'name'    => $result['name'], 
in

Code: Select all

/catalog/controller/product/category.php
Then in your category.tpl you need to use

Code: Select all

<?php echo $products[$j]['description']; ?>
inside the for loop of the products
My guess is you've not used the [$j]

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 6:55 pm
by i2Paq
JAY6390 wrote:You should have

Code: Select all

'description'    => preg_replace('/[\r\n\s]+/', ' ', strip_tags(substr(html_entity_decode($result['description']),0,80)))."...",  
after

Code: Select all

                        'name'    => $result['name'], 
in

Code: Select all

/catalog/controller/product/category.php
Then in your category.tpl you need to use

Code: Select all

<?php echo $products[$j]['description']; ?>
inside the for loop of the products
My guess is you've not used the [$j]
Nope, still the same error :(

Code: Select all

Notice: Undefined index: description in /var/www/vhosts/oc-directory.info/subdomains/oc148/httpdocs/catalog/view/theme/default/template/product/category.tpl  on line 54
category.tpl

Code: Select all

<table class="list">
      <?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td style="width: 25%;"><?php if (isset($products[$j])) { ?>
          <a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" /></a><br />
          <a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
          <span class="smallText"><?php echo $products[$j]['model']; ?></span><br />
          <?php echo $products[$j]['description']; ?>
          <?php if ($display_price) { ?>
          <?php if (!$products[$j]['special']) { ?>
          <span class="price"><?php echo $products[$j]['price']; ?></span>
          <?php } else { ?>
          <div class="price"><span class="ifspecial"><?php echo $products[$j]['price']; ?></span> <span class="special"><?php echo $products[$j]['special']; ?></span></div>
          <?php } ?>
          <?php } ?>
          <a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
          <br />
          <?php if ($products[$j]['rating']) { ?>
          <img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
          <?php } ?>
          <?php } ?></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </table>

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:10 pm
by JAY6390
Can you post your controller code for
/catalog/controller/product/category.php

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:23 pm
by i2Paq
JAY6390 wrote:Can you post your controller code for
/catalog/controller/product/category.php
Sure!

Code: Select all

$this->data['categories'][] = array(
                        'name'  => $result['name'],
                        'description'  => preg_replace('/[\r\n\s]+/', ' ', strip_tags(substr(html_entity_decode($result['description']),0,80)))."...",
                        'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
                        'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
                      );
                }
 

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:34 pm
by JAY6390
Well theres the problem right there, you're adding it to the categories array, you should be adding it to the

Code: Select all

$this->data['products'][] 
array instead (should be further down the code)

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:45 pm
by i2Paq
JAY6390 wrote:Well theres the problem right there, you're adding it to the categories array, you should be adding it to the

Code: Select all

$this->data['products'][] 
array instead (should be further down the code)
Yep, your right. Now it works ;)

It will show the ..., can we make the .... click-able?

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 7:53 pm
by JAY6390
yeah, to what exactly?

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 8:06 pm
by i2Paq
JAY6390 wrote:yeah, to what exactly?
To the product itself.

Better would be that the whole Short Description would be click-able.

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 9:14 pm
by Qphoria
When you add

Code: Select all

<?php echo $products[$j]['description']; ?>
to the tpl
change it to

Code: Select all

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

Re: Short Product Description / Description Excerpt

Posted: Wed Jul 07, 2010 9:51 pm
by JAY6390
Yup that'll do it

Re: Short Product Description / Description Excerpt

Posted: Thu Jul 08, 2010 4:48 pm
by i2Paq
yep, works like a charm.

What to do to have the Price always below the text?
Sometimes the currency-sign is next to the text and the price is on the next line/row.
This does not look that good ;)

Re: Short Product Description / Description Excerpt

Posted: Thu Jul 08, 2010 5:24 pm
by fido-x
In your template file (catalog/view/theme/YOUR_TEMPLATE/template/product/category.tpl), find:

Code: Select all

<?php if ($display_price) { ?>
and insert a <br /> after it.

Re: Short Product Description / Description Excerpt

Posted: Thu Jul 08, 2010 5:55 pm
by i2Paq
fido-x wrote:In your template file (catalog/view/theme/YOUR_TEMPLATE/template/product/category.tpl), find:

Code: Select all

<?php if ($display_price) { ?>
and insert a <br /> after it.
Yep, thanks :)

I tried </br> but that did not do it.

Re: Short Product Description / Description Excerpt

Posted: Thu Jul 08, 2010 6:31 pm
by JAY6390
eek avoid <br/> 's all you can. Use a div instead around it. That should work