Post by omar_ali222 » Tue Aug 05, 2014 9:30 pm

hello , I hope you are well guys .

1- When the product has a long name ,I want to shorten it when it appears in the Homepage.

2- How do I control the number of lines .

Attachments

how sddc.png

how sddc.png (97.97 KiB) Viewed 850 times


New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by Tcalp » Tue Aug 05, 2014 9:52 pm

You'd want to use sub string to shorten off the text:
http://php.net/manual/en/function.substr.php

Increase Page Speed (#1 rated commercial extension on OpenCart Marketplace)
15in1 Essential Extensions Value Pack Premium Customer Testimonials Reward Points Extended Admin Security Lockdown Suite

Image
irc.freenode.net #opencart


User avatar
Active Member

Posts

Joined
Wed Jul 06, 2011 1:49 pm

Post by omar_ali222 » Tue Aug 05, 2014 9:59 pm

Tcalp thanks

Could you give me steps more clearly Where can I put these ,please

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by omar_ali222 » Thu Aug 07, 2014 9:50 pm

hello guys
Could anyone explain me more clear please

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm

Post by Dhaupin » Fri Aug 08, 2014 2:53 am

It looks like your titles are already using substr(). To shorten them just adjust the last number in the operation. This is most likely found in the conroller for your list, module, feed, or other area. These are found in yourstore/catalog/controller/ in whatever folder is applicable. So find the controller file you need and look for the title var or whatever is making product titles.

For example, it may look something like this in one of those controllers:

Code: Select all

substr($result['name'], 0, 100)
What does it mean?
- Cut the output of $result['name'] off when i say
- Start from 0 which is the first char
- Count 100 chars of $result['name'] then stop
- Only output 100 chars of $result['name']

By changing the 100, it changes the chars it outputs from the string/title. So if you enter 50, it will make your titles half as long. Keep in mind, each area of display probably has its own controller, so adjust it everywhere :)

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA

Post by omar_ali222 » Sat Aug 09, 2014 4:18 am

Dhaupin wrote:It looks like your titles are already using substr(). To shorten them just adjust the last number in the operation. This is most likely found in the conroller for your list, module, feed, or other area. These are found in yourstore/catalog/controller/ in whatever folder is applicable. So find the controller file you need and look for the title var or whatever is making product titles.

For example, it may look something like this in one of those controllers:

Code: Select all

substr($result['name'], 0, 100)
What does it mean?
- Cut the output of $result['name'] off when i say
- Start from 0 which is the first char
- Count 100 chars of $result['name'] then stop
- Only output 100 chars of $result['name']

By changing the 100, it changes the chars it outputs from the string/title. So if you enter 50, it will make your titles half as long. Keep in mind, each area of display probably has its own controller, so adjust it everywhere :)

thank you so much thanks

New member

Posts

Joined
Mon Apr 22, 2013 9:10 pm
Who is online

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