Jump to content

Format in description not working


Recommended Posts

In the short description box for products, there are options for formatting the text: bold, colour, italics, add a link and so on. I can set bold and colour and so on, but not italics.

 

At least, I can add an italic book title, and it shows on the buttons that I have done so (but it doesn't look italic in the Short Description, though bold and colour does show). If I use the html editor, I see this:

 

<p><strong><span style="color: #000080;"><em>The Last Adventure</em></span> by Alan Thomas</strong></p>

 

If I change the <em> (and </em>) to ,i. and 'Update' then check again, nothing has saved or changed.

 

On the resulting product page, bold and colour and so on all display, but not italics. Italics (and other formatting) does display correctly if typed into the Description box.

 

Somewhat oddly, the title is not in bold inside Viewed Products in the side column, either - though it is correct on the product page.

 

I don't know where to look to try to fix this - has anyone any idea? Thanks for your time ...

 

 

Link to comment
Share on other sites

Okay - but that is the part that doesn't work for me. Using 1.5.6.1, and setting italics doesn't produce any effect at all, either in the short description area or in the web page it produces. Bold, links, colour, all the rest works - but not italics.

Link to comment
Share on other sites

It was from Theme Maker - I guess this has introduced an error, but I don't know where to look to try to fix it. The website had a lot of good reviews, but it seems to have broken this bit. It is supposed to only change colours, and otherwise is based on the default theme.

 

Is there an area of code I can look at to try to fix whatever has gone wrong? Everything works except italics - and they work in the other boxes, just not here.

Link to comment
Share on other sites

Many, many thanks for your help. The site is being developed and is not yet up and running, so I have had a maintenance block in operation. I have now taken it down so the site can be seen at: www.wildplaces.co.uk/shop, but I'll put the block back once you have seen it.

 

Thank you - I appreciate your time.

Link to comment
Share on other sites

Pretty much any part.

 

Home page: Featured Products, the title of each book is set to italics but none of these display. In left column, in New and Viewed, the same: the word 'Descent' should be in italics.

 

On any product page, example the first book (Images Below), the Short Description is just below the heading and is set to italics (which don't show). But in the Description box (which shows in the tabs) the italics show up. Anywhere that the text is entered using the Short Description, no italic text shows up (but bold, links, colour, all the rest are okay).

 

Thanks for helping.

Link to comment
Share on other sites

open module template file (.tpl) for example homefeatured.tpl

 

tere is a code like:

{$product.description_short|strip_tags|truncate:65:'...'}

you have to remove this: |strip_tags

{$product.description_short|truncate:65:'...'}

you ahve to do the same for all other template files where you've got this problem.

Link to comment
Share on other sites

I've looked in a few .tpl files. Taking the one you have as an example, homefeatured.tpl, I have this code:

 

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>
 

 

Which isn't quite the same as yours. This is the only place that strip_tags shows up (there are two of them here).

 

If I remove |strip_tags:'UTF-8' in both, the page does change. The gap between the heading and the short description text increases, but the formatting does not change.

 

In blockviewed.tpl, the code is here (only one instance of strip_tags):

 

description_short|strip_tags:'UTF-8'|truncate:44}</a></p>

 

Removing |strip_tags:'UTF-8' causes the text to become bolder and bigger, and spread outside the box for lack of space, but no italics return

 

Is what I tried correct?

Link to comment
Share on other sites

take a look on this example:

you've got this code in $product.description_short variable

<p style="font-size:20px"><span>test</span></p>

to display it you use:

{$product.description_short|truncate:36:'...'}

how the code will looks like? script will remove chars above the 36, in effect, it will looks like:

 

<p style="font-size:20px"><span>test</span></p>

<p style="font-size:20px"><span>test

this will causing a lot of problems, because <p> and <span> are unclosed! this is why |strip_tags is important when you use |truncate

Link to comment
Share on other sites

Thank you for helping. I'm afraid this is still a long way beyond me, though I'm trying to understand. I'm just not sure what I should actually do - what change I should make?

 

If you need to look at the site again, it is now in www.wildplaces.co.uk/shop1 (I am having so many problems I moved it so that I could put another installation in the original directory)

 

Thank you again - I'm sorry for my lack of knowledge.

Link to comment
Share on other sites

In homefeatured.tpl

 

the path is: www.wildplaces.co.uk/shop1/themes/axajeio/modules/homefeatured/homefeatured.tpl (I have pasted the contents below):

 

If I change:

 title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>

 

to:

 title="{$product.description_short}" >{$product.description_short}</a></p>

 

There is no change. I've also tried other variations of changing these lines (around line 48), like only taking out the |strip_tags bit and leaving the rest, with no success. Sorry - I do appreciate your time and help in trying to solve this (and I'm very aware of my lack of knowledge.

 

 

.......................................................

 

 

<!-- MODULE Home Featured Products -->
<div id="featured-products_block_center" class="block clearfix">
    <h2>{l s='Featured products' mod='homefeatured'}</h2>
    {if isset($products) AND $products}
                              
                        
                        <ul id="product_list" class="products_block grid grid4 clearfix">
    {foreach from=$products item=product name=products}
        <li class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix">
            <div class="left_block">
                            {if isset($comparator_max_item) && $comparator_max_item}
                    <p class="compare">
                        <input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compareProducts) && in_array($product.id_product, $compareProducts)}checked="checked"{/if} autocomplete="off"/>
                        <label for="comparator_item_{$product.id_product}">{l s='Select to compare' mod='homefeatured'}</label>
                    </p>
                {/if}
            </div>
            <div class="center_block">
                <a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_image" title="{$product.name|escape:'htmlall':'UTF-8'}">
                    <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
                    {if isset($product.new) && $product.new == 1}<span class="new">{l s='New' mod='homefeatured'}</span>{/if}
                </a>
                <h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3>
                <p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>
            </div>
            <div class="right_block">
                            {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
                    {if ($product.allow_oosp || $product.quantity > 0)}
                        {if isset($static_token)}
                            <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
                        {else}
                            <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)|escape:'html'}" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
                        {/if}                        
                    {else}
                        <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span>
                    {/if}
                {/if}
                <a class="lnk_more" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View' mod='homefeatured'}">{l s='View' mod='homefeatured'}</a>
                <p class="price_container">
                {if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
                <div class="content_price">
                    {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
                </div>
                {if isset($product.online_only) && $product.online_only}<span class="online_only">{l s='Online only' mod='homefeatured'}</span>{/if}
                {/if}
                
                                </p>
            </div>
        </li>
    {/foreach}
    </ul>
               
    {else}
        <p>{l s='No featured products' mod='homefeatured'}</p>
    {/if}
</div>
<!-- /MODULE Home Featured Products -->

Link to comment
Share on other sites

This is really not a good idea. There's a reason why formatting in the description text is (and should be) blocked. And it is not just an invention of Presta Theme Maker, but this behaviour is also in the default Prestashop theme.

 

First of all, you need to remove also the truncate function to not to cut off any <tag> from the formatting. But in that case your long description texts will not look nice.

 

Even if you are willing to remove the truncate function - weird situations may occur:

 

post-48475-0-80645400-1390957711_thumb.png

 

One post contains <li> which totally breaks the design.

 

My conclusion is - everything is possible, of course. But in this case, you will need a more sofisticated solution than just simply deleting a few of letters from the code.

 

if you would like to try it anyway and you are using theme from Presta Theme Maker:

 

your_theme/modules/homefeatured/homefeatured.tpl

 

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|truncate:360:'...'}</a></p>

 

change to:

 

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short}</a></p>

 

Andrej

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

Thanks Andrej - I'll give this a try and report back.

 

But just to clarify: the default theme has bold headings in the blocks (all of them taht I have found), where this theme does not (switch themes and they come back so it is the theme that has lost the formatting). On the product page, italics show up in the default theme in the Short Description box, but not in this current theme. Switch back to the default theme, and they appear as they should.

 

Thanks for helping.

Link to comment
Share on other sites

Okay, I tried the code change. It increased the gap between the heading and short description text, but did not change anything else (so I put the file back as it was).

 

This feels so odd, because the product titles in the NEW block are in bold as they should be, but not in the VIEWED block (for example). But there again, the layout is different in these blocks (in the default and this new theme in use, both): NEW has the image above the bold title and text, but Viewed has the image on the left and the title (in bold in default, not in this theme) and text on the right. The code obviously differs for the layout - perhaps a clue, or not; I am not a coder, but just look for clues.

 

I think, though it looks odd to me, that the lack of italics in descriptions in block boxes must be a Prestashop thing. But it would still be good to find what is preventing the bold in titles inside block boxes, and why no italics show up in short descriptions in Product pages. The bold headings are set by Prestashop, it appears, but as mentioned before the italics are inserted by me when adding the product. The code is present, because I can either copy/paste it into an html file and it displays, or else just switch to default theme and it displays. It does not show visibly in tinymce editor, even though the code is in there (and can be inspected).

 

Andrej - I really appreciate your help. I think Theme Maker as a concept and working method is awesome and despite searching for hours for a theme to purchase that would do what I want, Theme Maker has been my best (and only) route to where I want to be. Thanks for your time and input.

Link to comment
Share on other sites

×
×
  • Create New...