设为首页收藏本站

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 532|回复: 1

PrestaShop: Global smarty template variables

[复制链接]
发表于 2014-6-23 02:50:00 | 显示全部楼层 |阅读模式
All of this variables you can use in template files (both modules and theme). Enjoy!
{$base_dir_ssl}URL of your store when SSL certificate is active
{$base_dir}URL of your store
{$cart}Information about cart. Read entries below for more informations
{$cart->id}ID of customer cart
{$cart->id_shop_group}ID of shop group (multistore feature)
{$cart->id_shop}ID of shop (multistore feature)
{$cart->id_address_delivery}ID of customer address delivery (only if order was made)
{$cart->id_address_invoice}ID of customer address invoice (only if order was made)
{$cart->id_currency}ID of cart currency
{$cart->id_customer}ID of customer for which cart belongs (only if customer is logged)
{$cart->id_guest}ID of shop guest
{$cart->id_lang}ID of cart language
{$cart->recycable}Bool value if recycable checked for this cart
{$cart->gift}Bool value if gift checed for this cart
{$cart->gift_message}Gift message
{$cart->mobile_theme}Bool value if cart was created on mobile device
{$cart->date_add}Date of cart creation
{$cart->date_upd}Date of cart update
{$cart->id_carrier}Id of cart carrier (if selected)
{$cart->checkedTos}Bool value if terms of service is checked
{$img_cat_dir} URL for the directory with categories images
{$img_ps_dir} URL for the directory with PrestaShop image
{$img_lang_dir} URL for the directory with languages images
{$img_sup_dir} URL for the directory with suppliers images
{$img_ship_dir} URL for the directory with carriers images
{$img_prod_dir} URL for the directory with products images
{$img_manu_dir} URL for the directory with manufacturers images
{$img_dir} URL for the directory with theme’s images
{$css_dir} URL for the directory with theme’s CSS
{$modules_dir} URL for the directory with modules
{$mail_dir} URL for the directory with mail templates
{$js_dir} URL for the directory with theme’s JavaScript
{$tpl_dir} URL for the directory with current theme's
{$pic_dir} URL for the directory with uploaded pictures
{$lang_iso} ISO code for the current language
{$cart_qties} Number of products in the cart
{$come_from} URL for the visitor’s origin
{$shop_name} Shop name
{$currency} Currency object (currently used currency).
{$currencies} The various available currencies
{$id_currency_cookie} ID of the current currency
{$cookie} User cookie
{$languages} The various available languages
{$priceDisplay} Price display method (with or without taxes…)
{$roundMode} Rounding method in use
{$logged} Indicates whether the visitor is logged to a customer account
{$page_name} Page name
{$customerName} Client name (if logged in)
{$use_taxes} Indicates whether taxes are enabled or not

来自圈子: Demo俱乐部
 楼主| 发表于 2014-6-23 02:56:45 | 显示全部楼层
Prestashop 1.5 has a small problem in multistore.

This is a good thing to add in your FrontController.php if for example you have 2 different shops with different themes, and you want to access a few multistore smarty variables


In /classes/controller/FrontController.php find inside public function init() { and add:
  1. // Super Assign Multi Store
  2.   $this->context->smarty->assign(array(
  3.    'ms_id' => $this->context->shop->id, // Shop ID
  4.    'ms_name' => $this->context->shop->name, // Shop Name
  5.    'ms_status' => $this->context->shop->active, // Shop Status
  6.    'ms_theme' => array(
  7.                    'id' => $this->context->shop->id_theme,  // Shop Theme ID
  8.                    'name' => $this->context->shop->theme_name,  // Shop Theme Name
  9.                    'dir' => $this->context->shop->theme_directory // Shop Theme Directory
  10.                    ),
  11.    'ms_domain' => $this->context->shop->domain, // Shop Domain
  12.    'ms_domain_ssl' => $this->context->shop->domain_ssl, // Shop Domain with SSL
  13.    'ms_physical_uri' => $this->context->shop->physical_uri, // Shop Physical URL
  14.    'ms_virtual_uri' => $this->context->shop->virtual_uri, // Shop Virtual URL
  15.   ));
复制代码

and in your templates you can use all $ms_* smarty variables. A 5 minute useful trick.

--------------------------------------- use override, it will avoid to lost all after an update of Prestashop
like this :

in /override/classes/controller/FrontController.php
  1. <?php
  2. class FrontController extends FrontControllerCore
  3. {

  4. public function init()
  5. {
  6.   parent::init();
  7.   $this->context->smarty->assign(array(
  8.           'ms_id' => $this->context->shop->id, // Shop ID
  9.           'ms_name' => $this->context->shop->name, // Shop Name
  10.           'ms_status' => $this->context->shop->active, // Shop Status
  11.           'ms_theme' => array(
  12.                   'id' => $this->context->shop->id_theme,  // Shop Theme ID
  13.                   'name' => $this->context->shop->theme_name,  // Shop Theme Name
  14.                   'dir' => $this->context->shop->theme_directory // Shop Theme Directory
  15.                   ),
  16.           'ms_domain' => $this->context->shop->domain, // Shop Domain
  17.           'ms_domain_ssl' => $this->context->shop->domain_ssl, // Shop Domain with SSL
  18.           'ms_physical_uri' => $this->context->shop->physical_uri, // Shop Physical URL
  19.           'ms_virtual_uri' => $this->context->shop->virtual_uri, // Shop Virtual URL
  20.          ));
  21. }
  22. }
复制代码



您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )  

GMT-8, 2025-10-24 15:15 , Processed in 0.015788 second(s), 17 queries .

Supported by Best Deal Online X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表