Limit Title Characters on Product Listing Page

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #78857

Is there a way to limit the amount of characters shown for products on the products listing page????

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 11 months ago #78893

Hi,

The best way is to modify the view and add a limitation where the product name is displayed (using "substr").

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #79015

So would i do somthing like :

<?php
$rest = substr(, 0, -7);

?>

Last edit: 11 years 11 months ago by foxy3433.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 11 months ago #79035

Hi,

Yes, something like:

<?php
echo substr($this->row->product_name, 0, 7); //To display 7 characters.
?>
or do that with "$this->row->product_description", depending on what you want
Be careful, in the string "$this->row->product_description" it could be html tags.

The following user(s) said Thank You: foxy3433

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80123

When trying to edit the product listing page

i.e

Click on a category and you see all your products in that category with add to cart button..

Which file edits this file via VIEW?

Last edit: 11 years 11 months ago by foxy3433.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 11 months ago #80172

Hi,

The view to edit is depending on your configuration, if you set a display in Div with image and title displayed, then the view is "product / listing_img_title".

The following user(s) said Thank You: foxy3433

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80198

oo my Gosh why am i going on stupid Cheers Mate

Think i need sleep

Sorry for wasting you time that was a stupid question now awake had a bit of sleep

SORRY

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80216

Right i now have five mins to implement the character limit

So we have product name listed here:

<!-- PRODUCT NAME -->
<span class="hikashop_product_name">
<?php if($this->params->get('link_to_product_page',1)){ ?>
<a href="<?php echo $link;?>">


<?php }
echo $this->row->product_name;
if($this->params->get('link_to_product_page',1)){ ?>
</a>
<?php } ?>
</span>
<!-- EO PRODUCT NAME -->

I need to insert the title limit and manufactures name at the start i.e

<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?>

Any time i input the codes i get nothing, but it works fine on show_block???

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80234

<!-- PRODUCT NAME -->
<span class="hikashop_product_name">
<?php if($this->params->get('link_to_product_page',1)){ ?>
<a href="<?php echo $link;?>">


<?php
echo substr($this->row->product_name, 0, 7); //To display 7 characters.
?>
</a>
<?php } ?>
</span>
<!-- EO PRODUCT NAME -->

That's the title limited Figured it out

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80239

Unable to get Manufacture name in Title on Product listing page

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 11 months ago #80240

Are you sure that you edit in the good view of the good template ?

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80241

Ye i got the Limit working fine for the title but need the brand name to appear in Title also... Code i got won't work

<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?>

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 11 months ago #80256

I tried this code on my end, and it's working fine, try to add it just after the code:

<?php
echo substr($this->row->product_name, 0, 7); //To display 7 characters.
?>

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80260

Right we are confused i Sorted The Limit out i need the BRAND name to come up before title is this possible~????

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 11 months ago #80338

Hi,

Yes I understood that you have solved the limit problem, and I was telling you to try to add the code:

<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?> 
Before:
<?php
echo substr($this->row->product_name, 0, 7); //To display 7 characters.
?>

Because I tried the code:
<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?> 

And it's working fine on my end. ;)

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80363

ooo ok i'll try it now cheers mate

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80405

Nunno whats going on but that don't work my end, plus i have to be in the correct file as the limit is working

<!-- PRODUCT NAME -->
<span class="hikashop_product_name">
<?php if($this->params->get('link_to_product_page',1)){ ?>
<a href="<?php echo $link;?>">

<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?><?php echo substr($this->row->product_name, 0, 30); //To display 7 characters.
?>
</a>
<?php } ?>
</span>
<!-- EO PRODUCT NAME -->

You want BK-End Access to explore or url to page to view source?

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 11 months ago #80454

Hi,

<!-- PRODUCT NAME -->
<span class="hikashop_product_name">
<?php if($this->params->get('link_to_product_page',1)){ ?>
<a href="<?php echo $link;?>">

<?php
$categoryClass = hikashop_get('class.category');
$manufacturer = $categoryClass->get($this->row->product_manufacturer_id);
echo $manufacturer->category_name;
echo substr($this->row->product_name, 0, 30);
?>
</a>
<?php } ?>
</span>
<!-- EO PRODUCT NAME -->

PS : You can use the tag "code" for pasting your code, it would be easier to read :)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 11 months ago by Jerome.
The following user(s) said Thank You: foxy3433

Please Log in or Create an account to join the conversation.

  • Posts: 81
  • Thank you received: 6
11 years 11 months ago #80487

That worked..... Thank you..

Have we not got a MYSQL Query to just bang the brand name in title of product cause i need it on checkout and cart...

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 11 months ago #80558

The code is the same there too:
<?php $class = hikashop_get('class.category');
$manufacturer = $class->get($this->element->product_manufacturer_id);
echo $manufacturer->category_name; ?>

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum