Jump to content

[SOLVED] How to stop truncation of item names in product list?


Recommended Posts

Hello all: I'm new here, and in the processing of setting up my PrestaShop for launch next month. Love the software, but I have a number of questions I'll be seeking help with over the next couple of weeks. For reference, I have extensive experience working with WordPress code, so I can handle fairly advanced issues and modifications. However, I don't consider myself a coder and I especially don't understand the ins and outs of how PrestaShop works.

 

The Question:

I would like to stop the truncation of item titles in the product list. (For example, when a users clicks on a category.) I have read on this forum that to do this, I just need to modify product_list.tpl in coremanager. However, I cannot find coremanager--has it been removed from the current version? I tried to go to: modules/coremanager/modules as direction, but it doesn't seem to exist.

 

I did edit the product_list.tpl file in the theme directory, but it didn't affect any change on the item names. They were still truncated.

 

Any help or advice on this is appreciated.

 

- Nikki

Share this post


Link to post
Share on other sites

Hi Nikki,

First of all, welcome to PrestaShop! As for your issue, can you post a screenshot of a spot on your site having this issue? Is it just the character limit or something beyond that?

 

-Mike

 

Hey Mike, thanks for the quick reply. I have attached a screenshot as requested.

You'll see what I mean on the second item in the list, "Angel of Flight Alabaster." Whereas the other items with shorter titles feature the full name (including "Innistrad X/YZ), the case of "Angel of Flight," the title truncates because it exceeds the character limit.

 

I did try modifying the character limit in the theme's product_list.tpl file, but it didn't make any change.

post-320212-0-57749700-1327348427_thumb.jpg

Share this post


Link to post
Share on other sites

Hi Nikki,

In your theme's product-list.tpl file, locate the following line (should be around line 42 in v1.4.6.2)

{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}

 

and increase the truncate value from 35 to whatever you would like it to be.

 

Once you do so, please be sure to go to your Back Office under Preferences > Performance and turn on Force Compile turn off Caching to ensure that you are seeing the latest version of your updates.

 

Please let me know if this works for you.

 

-Mike

  • Like 1

Share this post


Link to post
Share on other sites

Great, I'm glad I could help! What Force Compile does is require the site to load from scratch each time rather than drawing from your browser cache. It's not recommended for a live environment because it will noticeably slow down your site, but when it comes to debugging or making changes, it's a huge time-saver. I'll go ahead and mark this thread as solved for you, and once again, welcome to PrestaShop!

 

-Mike

Share this post


Link to post
Share on other sites
  • 2 months later...
  • 6 months later...

Hi,

 

and do you know how to do the same but regarding the subcategory names? I've looked for something similar than truncate:... in the source code, concretely in /modules/productscategory/productscategory.tpl, but it doesn't change anything (with recompilation).

 

{$categoryProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}

 

Thanks in advance!!

post-370052-0-83848300-1353055820_thumb.png

Share this post


Link to post
Share on other sites
  • 1 year later...

and do you know how to do the same but regarding the subcategory names? I've looked for something similar than truncate:... in the source code, concretely in /modules/productscategory/productscategory.tpl, but it doesn't change anything (with recompilation).

 

{$categoryProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}

 

Thanks in advance!!

 

 

UP ! this is super interesting thing ! i tried also to check category.tpl :

 

title="{$subcategory.name|escape:'htmlall':'UTF-8'}" >{$subcategory.name|escape:'htmlall':'UTF-8'}</a>

 

 

but here no truncate appear..why ? i tried also to modify /modules/productscategory/productscategory.tpl ({$categoryProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}) but with no success ! (after deleting cache/ compile/ of course)

 

 

needing help !!

Share this post


Link to post
Share on other sites
  • 2 years later...

Great, I'm glad I could help! What Force Compile does is require the site to load from scratch each time rather than drawing from your browser cache. It's not recommended for a live environment because it will noticeably slow down your site, but when it comes to debugging or making changes, it's a huge time-saver. I'll go ahead and mark this thread as solved for you, and once again, welcome to PrestaShop!

 

-Mike

 

Hello Mike, I know this is an old post, but I was wondering if you know if there's a way to have different truncate values for mobile?

thanks!!

Share this post


Link to post
Share on other sites
  • 2 years later...

I just found a way to NEVER truncate by just removing part of the code, changing part of the code of our friend Infor-All.

1. Go to /public_html/themes/YourTheme/templates/catalog/_partials/miniatures/product.tpl

2. Change 

    <div class="product-description">
        {block name='product_name'}
          {if $page.page_name == 'index'}
            <h3 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h3>
          {else}
            <h2 class="h3 product-title" itemprop="name"><a href="{$product.canonical_url}">{$product.name|truncate:30:'...'}</a></h2>
          {/if}
        {/block}

To:

 <div class="product-description">
        {block name='product_name'}
          {if $product.name|count_characters > 35}
          {if $page.page_name == 'index'}
                <h3 class="h3 product-title" style="margin-top: -0.1rem;" itemprop="name">
                  <a href="{$product.url}">{$product.name}</a>
                </h3>
            {else}
              <h2 class="h3 product-title" style="margin-top: -0.1rem;" itemprop="name">
                <a href="{$product.url}">{$product.name}</a>
              </h2>
            {/if}
          {else}
            {if $page.page_name == 'index'}
                <h3 class="h3 product-title" itemprop="name">
                  <a href="{$product.url}">{$product.name}</a>
                </h3>
            {else}
              <h2 class="h3 product-title" itemprop="name">
                <a href="{$product.url}">{$product.name}</a>
              </h2>
            {/if}
          {/if}
        {/block}

Basically I just removed the truncate, changing "{$product.name|truncate:30:'...'}" to "{$product.name}"

Then Recompile your files (Advanced Parameters - Performance - Smarty 

Change "never recompile" to"recompile files", clear cache, change back to never recompile

I use Prestashop 1.7.0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More