Jump to content

How to display image in .tpl file?


Recommended Posts

If you image is in the theme directory use prestasho smarty theme image variable



(please ensure you upload your image to themes/youtheme/img) ;)

you will find all the variables for different directories for you store located in the init.php line 95

example

$smarty->assign(array(
'base_dir' => __PS_BASE_URI__,
'base_dir_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__,
/* If the current page need SSL encryption and the shop allow it, then active it */
'protocol' => $protocol,
'img_ps_dir' => _PS_IMG_,
'img_cat_dir' => _THEME_CAT_DIR_,
'img_lang_dir' => _THEME_LANG_DIR_,
'img_prod_dir' => _THEME_PROD_DIR_,
'img_manu_dir' => _THEME_MANU_DIR_,
'img_sup_dir' => _THEME_SUP_DIR_,
'img_ship_dir' => _THEME_SHIP_DIR_,
'img_col_dir' => _THEME_COL_DIR_,
'img_dir' => _THEME_IMG_DIR_,
'css_dir' => _THEME_CSS_DIR_,
'js_dir' => _THEME_JS_DIR_,
'tpl_dir' => _PS_THEME_DIR_,
'mail_dir' => _MAIL_DIR_,
'lang_iso' => $ps_language->iso_code,
'come_from' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').htmlentities($_SERVER['REQUEST_URI']),
'shop_name' => Configuration::get('PS_SHOP_NAME'),
'cart_qties' => intval($cart->nbProducts()),
'cart' => $cart,
'currencies' => Currency::getCurrencies(),
'id_currency_cookie' => intval($currency->id),
'currency' => $currency,
'languages' => Language::getLanguages(),
'logged' => $cookie->isLogged(),
'page_name' => $page_name,
'customerName' => ($cookie->logged ? $cookie->customer_firstname.' '.$cookie->customer_lastname : false)
));

Link to comment
Share on other sites

  • 4 weeks later...

Hi

I have successfully added new pages and images to new tpl files but I’ve hardcoded the image links. :red:
I now wish to change the image links to smarty variables but I can’t get the correct syntax

I tried




which gives




and




which gives

Fatal error: Smarty error: [in /home/www/my_site.co.uk/themes/my_theme/restore.tpl line 6]: syntax error: invalid attribute name: '>' (Smarty_Compiler.class.php, line 1547) in /home/www/my_site.co.uk/tools/smarty/Smarty.class.php on line 1097



and




which gives





What is the correct syntax to use smarty variables in tpl files?


Regards

Ken.

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 years later...
×
×
  • Create New...