Jump to content

How to make Superscript format ® symbol in Category name and Product name


borisdifiore

Recommended Posts

Hi,

I would like to make ® symbol in superscript format in Category name field and Product name field.

Actually I'm not able to get in the fields Category name end Product name the ® 

for example: I want to get this : Category® Product® and I get this Category® and Product®

I can't use <sup>R<sup> command in category and product name fields due to <> are forbidden...

 

Any suggestion?

Thank you in advance
Boris

 

 

Link to comment
Share on other sites

Since PrestaShop doesn't allow HTML in category and product names, I think you'll have to modify all the references to the category names and product names in your theme's TPL files. For example, in product.tpl, change all references like this:

{$product->name|escape:'html':'UTF-8'}

to this:

{$product->name|escape:'html':'UTF-8'|replace:'®':'<sup>®</sup>'}

Add that replace part to all the right strings and the ® will become superscript.

  • Like 1
Link to comment
Share on other sites

It doesn't work I make changes in product.tpl in theme/default-boostrap/product.tpl.....

:(


 

Since PrestaShop doesn't allow HTML in category and product names, I think you'll have to modify all the references to the category names and product names in your theme's TPL files. For example, in product.tpl, change all references like this:

{$product->name|escape:'html':'UTF-8'}

to this:

{$product->name|escape:'html':'UTF-8'|replace:'®':'<sup>®</sup>'}

Add that replace part to all the right strings and the ® will become superscript.

Link to comment
Share on other sites

It works fine on my PrestaShop v1.6.1.6 test site. I changed line 158 of themes/default-bootstrap/product.tpl from:

            <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'}</h1>

to:

            <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'|replace:'®':'<sup>®</sup>'}</h1>

Then I see the following:

 

post-13933-0-05422400-1468729141_thumb.png

  • Like 1
Link to comment
Share on other sites

Done the some and also cache cleared after the line change you suggested,

but unfortunately I didn't get the successfully result you got.... that is exactly what I want for products and Categories

I have in production the some Prestashop version you tested :(

 

 

It works fine on my PrestaShop v1.6.1.6 test site. I changed line 158 of themes/default-bootstrap/product.tpl from:

            <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'}</h1>

to:

            <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'|replace:'®':'<sup>®</sup>'}</h1>

Then I see the following:

 

attachicon.gifscreenshot.png

Link to comment
Share on other sites


 

There's nothing more I can do unless I log in to your website and try it myself.

 

 

Thank you Rocky for your interest and help, but my costumer denied to allow your log in fr security reasons. Don't take it personal....
Something is going wrong but I can't understand why....
 

Link to comment
Share on other sites

@rakepl

 

Yes, you could do that by overriding the Tools::displayPrice function and modifying the formatNumber JavaScript function. For example, create override/classes/Tools.php with the following:

<?php

class Tools extends ToolsCore
{
    public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null)
    {
        $formatted_price = ToolsCore::displayPrice($price, $currency, $no_utf8, $context);
        
        if ($currency === null) {
            $currency = $context->currency;
        } elseif (is_int($currency)) {
            $currency = Currency::getCurrencyInstance((int)$currency);
        }

        if (is_array($currency)) {
            $c_format = $currency['format'];
        } elseif (is_object($currency)) {
            $c_format = $currency->format;
        } else {
            return false;   
        }
        
        $decimal = (($c_format == 2 || $c_format == 3) ? ',' : '.');
        
        return str_replace($decimal, '<sup>', $formatted_price).'</sup>';
    }
}

and then change line 56 of js/tools.js from:

	return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');

to:

//	return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
	return abs_val_string + '<sup>' + (deci_string > 0 ? deci_string : '00').'</sup>';

Remember to go to Advanced Parameters > Performance and then click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop finds the override.

Link to comment
Share on other sites

  • 5 months later...

No, I'd have to search like you can search too, and it depends a lot from the settings and modules you are using.

 

This forum is to help you to help yourself, not to do all your work.

Thank you for your time. I was not asking to do my job, and before ask I already search but without success. I know the philosophy of the forum.

have a nice day

Link to comment
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...