Prestashop 1.6.1.11如果用户没有登录显示(这。)

时间:2017-02-21 11:14:13

标签: php smarty prestashop prestashop-1.6

目前正试图绕过Prestashop,1.6.1.11。我理解了一点,但我不会说我有经验。

我正在检查用户是否已登录,我在其他地方使用.tpl文件找到了这个示例。但是,如果用户未登录,我需要执行响应。我找到的线程与之相反。

  

e.g。如果用户未登录show element。

我在prestashop论坛上找到了这一行{if $logged} ..... {/if},但线程相当陈旧,我不确定这是否可以追溯到版本1.5。我可能在这里表现出我的经验不足,但在你问之前你不知道。

我想要实现的具体目的是显示一个完整的宽度/高度图像,并在中心顶部叠加一个登录元素。

我想基本上只为用户提供一个与之交互并用于登录的元素。

我希望我已经解释得很好,任何帮助都表示赞赏。我会继续寻找,如果我找到任何有用的东西,我会在这里发布。

修改

Link to Prestashop thread.

My Own Prestashop question.

1 个答案:

答案 0 :(得分:1)

因此经过一些挖掘,我能够使用以下内容来获得我想要的功能。

<!-- Check Login -->
<div id="check-log">
  {if $is_logged}

    <a href=".." id="Logout" />Logout</a>

  {else}

    <a href=".." id="Login" />Login</a>

  {/if}
</div>

此代码应放在header.tpl主题文件中。

此变量在方法/classes/controller/FrontController.php中的类init()中定义:

$this->context->smarty->assign(array(
    // Useful for layout.tpl
    'mobile_device'       => $this->context->getMobileDevice(),
    'link'                => $link,
    'cart'                => $cart,
    'currency'            => $currency,
    'currencyRate'        => (float)$currency->getConversationRate(),
    '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'),
    'currencySign'        => $currency->sign, // backward compat, see global.tpl
    'currencyFormat'      => $currency->format, // backward compat
    'currencyBlank'       => $currency->blank, // backward compat
));

// Deprecated
$this->context->smarty->assign(array(
    'id_currency_cookie' => (int)$currency->id,
    'logged'             => $this->context->customer->isLogged(),
    'customerName'       => ($this->context->customer->logged ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : false)
));