Post by Qphoria » Wed Jul 07, 2010 12:35 am

updated for earlier versions

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by i2Paq » Wed Jul 07, 2010 12:41 am

What would the code be if used only on the product-listing page?

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by helenmarie » Wed Jul 07, 2010 1:32 am

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

User avatar
New member

Posts

Joined
Sat Nov 07, 2009 1:05 am

Post by i2Paq » Wed Jul 07, 2010 3:24 am

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

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by helenmarie » Wed Jul 07, 2010 7:50 am

aah yeh same error here too :-\

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

:)

User avatar
New member

Posts

Joined
Sat Nov 07, 2009 1:05 am

Post by i2Paq » Wed Jul 07, 2010 3:22 pm

helenmarie wrote:aah yeh same error here too :-\

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

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

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Wed Jul 07, 2010 6:34 pm

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]

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Wed Jul 07, 2010 6:55 pm

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>

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Wed Jul 07, 2010 7:10 pm

Can you post your controller code for
/catalog/controller/product/category.php

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Wed Jul 07, 2010 7:23 pm

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'))
                      );
                }
 

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Wed Jul 07, 2010 7:34 pm

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)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Wed Jul 07, 2010 7:45 pm

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?

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Wed Jul 07, 2010 7:53 pm

yeah, to what exactly?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Wed Jul 07, 2010 8:06 pm

JAY6390 wrote:yeah, to what exactly?
To the product itself.

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

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by Qphoria » Wed Jul 07, 2010 9:14 pm

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>

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JAY6390 » Wed Jul 07, 2010 9:51 pm

Yup that'll do it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by i2Paq » Thu Jul 08, 2010 4:48 pm

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 ;)

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by fido-x » Thu Jul 08, 2010 5:24 pm

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.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by i2Paq » Thu Jul 08, 2010 5:55 pm

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.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by JAY6390 » Thu Jul 08, 2010 6:31 pm

eek avoid <br/> 's all you can. Use a div instead around it. That should work

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 13 guests