Jump to content

Displaying product title...


Recommended Posts

Hi All,

 

A minor annoyance, but a rather important one..

 

The shop I am currently building does not display the entier product name inwhen you view them in the category. It displays the beginning and then dots after that.

E.g.

 

This is how it should be:     "Long product name because it is long"

This is how it is doing it:      "Long product..."

 

It would be rather important to overcome this issue as the shop has many similar products with differences only in taste, but not look.

 

www.kolbaszaruhaz.hu if someone wants to have a look.

 

I have also attached a picture where I have outlined the issue with red and black :-)

 

Thx All for reading it.

post-656652-0-35187400-1387458764_thumb.png

Link to comment
Share on other sites

Hi.

 

You need to edit product-list.tpl, locate:

 

<h3>{if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if}<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}</a></h3>

 

By changing the number after 'truncate' you can set the length of the text.

 

Regards.

Robin.

The CartExpert Team

Link to comment
Share on other sites

Robin,

 

Where can I turn on and off these? Should thez be turned off or on?

I have found a file which I have pasted below.. it is the smarty.config.inc.php file

Would you mind to take a look at it???

 

Thanks

 

the file:

 

<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_SMARTY_DIR_', _PS_TOOL_DIR_.'smarty/');

require_once(_PS_SMARTY_DIR_.'Smarty.class.php');

global $smarty;
$smarty = new Smarty();
$smarty->setCompileDir(_PS_CACHE_DIR_.'smarty/compile');
$smarty->setCacheDir(_PS_CACHE_DIR_.'smarty/cache');
if (!Tools::getSafeModeStatus())
    $smarty->use_sub_dirs = true;
$smarty->setConfigDir(_PS_SMARTY_DIR_.'configs');
$smarty->caching = false;
$smarty->force_compile = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_FORCE_COMPILE_) ? true : false;
$smarty->compile_check = (Configuration::get('PS_SMARTY_FORCE_COMPILE') <= _PS_SMARTY_CHECK_COMPILE_) ? true : false;

// Production mode
$smarty->debugging = false;
$smarty->debugging_ctrl = 'NONE';

if (Configuration::get('PS_SMARTY_CONSOLE') == _PS_SMARTY_CONSOLE_OPEN_BY_URL_)
    $smarty->debugging_ctrl = 'URL';
else if (Configuration::get('PS_SMARTY_CONSOLE') == _PS_SMARTY_CONSOLE_OPEN_)
    $smarty->debugging = true;

/* Use this constant if you want to load smarty without all PrestaShop functions */
if (defined('_PS_SMARTY_FAST_LOAD_') && _PS_SMARTY_FAST_LOAD_)
    return;

if (defined('_PS_ADMIN_DIR_'))
    require_once (dirname(__FILE__).'/smartyadmin.config.inc.php');
else
    require_once (dirname(__FILE__).'/smartyfront.config.inc.php');

smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate');
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));

smartyRegisterFunction($smarty, 'function', 't', 'smartyTruncate'); // unused
smartyRegisterFunction($smarty, 'function', 'm', 'smartyMaxWords'); // unused
smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject'); // Debug only
smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject'); // Debug only
smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false);
smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook');
smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');

smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat'));
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));


function smartyDieObject($params, &$smarty)
{
    return Tools::D($params['var']);
}

function smartyShowObject($params, &$smarty)
{
    return Tools::P($params['var']);
}

function smartyMaxWords($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);

    foreach($words AS &$word)
        if(Tools::strlen($word) > $params['n'])
            $word = Tools::substr(trim(chunk_split($word, $params['n']-1, '- ')), 0, -1);

    return implode(' ',  Tools::htmlentitiesUTF8($words));
}

function smartyTruncate($params, &$smarty)
{
    Tools::displayAsDeprecated();
    $text = isset($params['strip']) ? strip_tags($params['text']) : $params['text'];
    $length = $params['length'];
    $sep = isset($params['sep']) ? $params['sep'] : '...';

    if (Tools::strlen($text) > $length + Tools::strlen($sep))
        $text = Tools::substr($text, 0, $length).$sep;

    return (isset($params['encode']) ? Tools::htmlentitiesUTF8($text, ENT_NOQUOTES) : $text);
}

function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false, $charset = 'UTF-8')
{
    if (!$length)
        return '';

    if (Tools::strlen($string) > $length)
    {
        $length -= min($length, Tools::strlen($etc));
        if (!$break_words && !$middle)
            $string = preg_replace('/\s+?(\S+)?$/u', '', Tools::substr($string, 0, $length+1, $charset));
        return !$middle ? Tools::substr($string, 0, $length, $charset).$etc : Tools::substr($string, 0, $length/2, $charset).$etc.Tools::substr($string, -$length/2, $length, $charset);
    }
    else
        return $string;
}

function smarty_modifier_htmlentitiesUTF8($string)
{
        return Tools::htmlentitiesUTF8($string);
}
function smartyMinifyHTML($tpl_output, &$smarty)
{
    $tpl_output = Media::minifyHTML($tpl_output);
    return $tpl_output;
}

function smartyPackJSinHTML($tpl_output, &$smarty)
{
    $tpl_output = Media::packJSinHTML($tpl_output);
    return $tpl_output;
}

function smartyRegisterFunction($smarty, $type, $function, $params, $lazy = true)
{
    if (!in_array($type, array('function', 'modifier')))
        return false;

    // lazy is better if the function is not called on every page
    if ($lazy)
    {
        $lazy_register = SmartyLazyRegister::getInstance();
        $lazy_register->register($params);

        if (is_array($params))
            $params = $params[1];

        // SmartyLazyRegister allows to only load external class when they are needed
        $smarty->registerPlugin($type, $function, array($lazy_register, $params));
    }
    else
        $smarty->registerPlugin($type, $function, $params);
}

function smartyHook($params, &$smarty)
{
    if (!empty($params['h']))
    {
        $id_module = null;
        $hook_params = $params;
        if (!empty($params['mod']))
        {
            $module = Module::getInstanceByName($params['mod']);
            if ($module && $module->id)
                $id_module = $module->id;
            unset($hook_params['mod']);
        }
        unset($hook_params['h']);
        return Hook::exec($params['h'], $hook_params, $id_module);
    }
}

function toolsConvertPrice($params, &$smarty)
{
    return Tools::convertPrice($params['price'], Context::getContext()->currency);
}

/**
 * Used to delay loading of external classes with smarty->register_plugin
 */
class SmartyLazyRegister
{
    protected $registry = array();
    protected static $instance;

    /**
     * Register a function or method to be dynamically called later
     * @param $params function name or array(object name, method name)
     */
    public function register($params)
    {
        if (is_array($params))
            $this->registry[$params[1]] = $params;
        else
            $this->registry[$params] = $params;
    }

    /**
     * Dynamically call static function or method
     *
     * @param $name function name
     * @param $arguments function argument
     * @return mixed function return
     */
    public function __call($name, $arguments)
    {
        $item = $this->registry[$name];

        // case 1: call to static method - case 2 : call to static function
        if (is_array($item[1]))
            return call_user_func_array($item[1].'::'.$item[0], array($arguments[0], &$arguments[1]));
        else
        {
            $args = array();
            
            foreach($arguments as $a => $argument)
                if($a == 0)
                    $args[] = $arguments[0];
                else
                    $args[] = &$arguments[$a];
            
            return call_user_func_array($item, $args);
        }
    }

    public static function getInstance()
    {
        if (!self::$instance)
            self::$instance = new SmartyLazyRegister();
        return self::$instance;
    }
}

 

Link to comment
Share on other sites

Soooooo

 

Under the smarty settings it is set to regenerate the templates if thez have been modified.

 

According to this they should be regenerated.

 

The title looks fine if you view the products in the category, but on the home page some of them is okay and some of them is not

You can see it on the main page of the site :-(

Link to comment
Share on other sites

Robin,

 

Yes, Yes,Yes !!!!

 

It must be noted that I needed to edit the one in the custom template rather than the default.

 

Thanks mate!!!

Do appriciate your help and time.

 

If the business kick is I will get you some sausages... There will be lot more than what it is in the shop now :-)

 

Regards

Tamás

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...