Jump to content

[solved] Edit Admin theme to truncate category description


Recommended Posts

Hi there, hopefully someone can help! I've trawled through the admin folders and controllers but nothing is catching my attention.

 

We have large descriptions for some of our categories, and therefore makes the admin section look ugly (when viewing the list of categories). Is there any way we can truncate the category descriptions just viewing the category list (don't want to truncate the actual description, just the view).

 

Thanks in advance

Link to comment
Share on other sites

Hi there, hopefully someone can help! I've trawled through the admin folders and controllers but nothing is catching my attention.

 

We have large descriptions for some of our categories, and therefore makes the admin section look ugly (when viewing the list of categories). Is there any way we can truncate the category descriptions just viewing the category list (don't want to truncate the actual description, just the view).

 

Thanks in advance

 

for the first, we must know what prestashop version you use

 

regards

Link to comment
Share on other sites

thanks

 

so you need to edit template file for helpers. It's easy.

Go to the YOUR_ADMIN_DIR/themes/default/template/helpers/list/list_content

 

near the ~103 line you've got:

 

 

{elseif isset($params.callback)}
{$tr.$key}

 

change it to:

 

{elseif isset($params.callback)}
{if $key=="description"}
{$tr.$key|substr:0:25} ...
{else}
{$tr.$key}
{/if}

 

the most important thing is: {$tr.$key|substr:0:25}

substr mean that we cutting this variable, only 25 first chars will appear. You can personalize this as you want.

 

 

remember that this is a smarty template, so you probably have to turn force compilation on in preferences -> performance to recompile the theme.

 

 

let me know if this works for you :-) or not ;)

  • Like 2
Link to comment
Share on other sites

Vekia, that's absolutely brilliant, thank you very much for your help and quick response. Works perfect :) Never would have thought to look in that file! Thanks again.

 

You're welcome :-)

Now i can go ahead and mark this thread as solved for other forum members

 

regards

Link to comment
Share on other sites

  • 3 weeks later...

I asked because I tried your solution and it did not work. Instead I used it in the category.tpl file.

Instead of (around line 95)

 

<p class="cat_desc">
{$subcategory.description}
</p>

I did:

<div class="cat_desc">
{if strlen($subcategory.description) > 200}
<p id="category_description_short">
{$subcategory.description|truncate:200}
</p>
<p id="category_description_full" style="display:none">
{$subcategory.description}
</p>
<a href="#" onclick="$('#category_description_short').hide(); $('#category_description_full').show(); $(this).hide(); return false;" class="lnk_more">
{l s='More'}
</a>
{else}
<p class="cat_desc">
{$subcategory.description}
</p>
{/if}
</div>

I am sure that the above code, is not 100% correct, but it does the trick of truncating the text. But it does not show the "More..." link.

Edited by kingsinnersoul (see edit history)
Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...