如何获得当前主题的URL中的Prestashop的.tpl文件及

问题描述:

我需要得到它位于www.mysite.com/themes/mytheme/img/image.png图像的路径如何获得当前主题的URL中的Prestashop的.tpl文件及

===== ============================================

I'我们在这里找到了答案:http://prestalab.ru/wiki/peremennye-v-shablonax

在我的主题图像的路径将是:{$ tpl_dir} IMG/myimage.png

+2

在PS1.6,你可以简单地使用'{$ tpl_uri}' - **不要使用{$ tpl_dir} '!** - 那一个是服务器上的绝对路径 - 你不想暴露那个...... :) –

没有为这是mytheme的IMG文件夹中的全局变量的Smarty - img_dir

查看所有的Smarty在的Prestashop全局变量: http://saidul.songzog.com/my-blog/details/848/smarty-global-variables-in-prestashop.html

$tpl_uri将返回当前主题的路径相对于Web根目录。

这里有一些其他的全局变量的PrestaShop使得其提供可能有益

$img_ps_dir  // the PrestaShop image directory 
$img_cat_dir  // current category's images directory 
$img_lang_dir  // current language's images directory 
$img_prod_dir  // current product's images directory 
$img_manu_dir  // current manufacturer's images directory 
$img_sup_dir  // current supplier's images directory 
$img_ship_dir  // current carrier's (shipping) images directory 
$img_dir   // current theme’s images directory 
$css_dir   // current theme’s CSS directory 
$js_dir   // current theme’s JavaScript directory 
$tpl_dir   // current theme’s directory (physical path on machine) 
$tpl_uri   // current theme's directory (web-root relative path) 
$modules_dir  // modules directory 
$mail_dir   // mail templates directory 
$pic_dir   // pictures upload directory 
+2

{$ tpl_dir}返回物理路径= c:\ wamp \ www –

+0

这里是一个可用的smarty列表变量在prestashop http://blog.gofenice.com/prestashop/global-smarty-variables-used-in-prestashop/ –

在PS 1.6,我发现我需要添加一个智者变量来得到我的主题的URI。在 类/关于线333控制器/ FrontController.php 其中tpl_dir被设置,我加入下面这行:

'tpl_uri' => _THEME_DIR_, 

它返回路径的主题。

有时它足够多看代码,查看分配所有基本变量:

// FrontController Class 
$this->context->smarty->assign(array(
     // Usefull for layout.tpl 
     'mobile_device' => $this->context->getMobileDevice(), 
     'link' => $link, 
     'cart' => $cart, 
     'currency' => $currency, 
     'cookie' => $this->context->cookie, 
     'page_name' => $page_name, 
     'hide_left_column' => !$this->display_column_left, 
     'hide_right_column' => !$this->display_column_right, 
     'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__, 
     'base_dir_ssl' => $protocol_link.Tools::getShopDomainSsl().__PS_BASE_URI__, 
     'force_ssl' => Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'), 
     'content_dir' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__, 
     'base_uri' => $protocol_content.Tools::getHttpHost().__PS_BASE_URI__.(!Configuration::get('PS_REWRITING_SETTINGS') ? 'index.php' : ''), 
     'tpl_dir' => _PS_THEME_DIR_, 
     'tpl_uri' => _THEME_DIR_, 
     'modules_dir' => _MODULE_DIR_, 
     'mail_dir' => _MAIL_DIR_, 
     'lang_iso' => $this->context->language->iso_code, 
     'lang_id' => (int)$this->context->language->id, 
     'language_code' => $this->context->language->language_code ? $this->context->language->language_code : $this->context->language->iso_code, 
     'come_from' => Tools::getHttpHost(true, true).Tools::htmlentitiesUTF8(str_replace(array('\'', '\\'), '', urldecode($_SERVER['REQUEST_URI']))), 
     'cart_qties' => (int)$cart->nbProducts(), 
     'currencies' => Currency::getCurrencies(), 
     'languages' => $languages, 
     'meta_language' => implode(',', $meta_language), 
     'priceDisplay' => Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer), 
     'is_logged' => (bool)$this->context->customer->isLogged(), 
     'is_guest' => (bool)$this->context->customer->isGuest(), 
     'add_prod_display' => (int)Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 
     'shop_name' => Configuration::get('PS_SHOP_NAME'), 
     'roundMode' => (int)Configuration::get('PS_PRICE_ROUND_MODE'), 
     'use_taxes' => (int)Configuration::get('PS_TAX'), 
     'show_taxes' => (int)(Configuration::get('PS_TAX_DISPLAY') == 1 && (int)Configuration::get('PS_TAX')), 
     'display_tax_label' => (bool)$display_tax_label, 
     'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'), 
     'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'), 
     'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE') || (Group::isFeatureActive() && !(bool)Group::getCurrent()->show_prices), 
     'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE'), 
     'request' => $link->getPaginationLink(false, false, false, true), 
     'PS_STOCK_MANAGEMENT' => Configuration::get('PS_STOCK_MANAGEMENT'), 
     'quick_view' => (bool)Configuration::get('PS_QUICK_VIEW'), 
     'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 
     'compared_products' => is_array($compared_products) ? $compared_products : array(), 
     'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 
     'currencyRate' => (float)$currency->getConversationRate(), 
     'currencySign' => $currency->sign, 
     'currencyFormat' => $currency->format, 
     'currencyBlank' => $currency->blank, 
    ));