【问题标题】:How to init langage index in a Prestashop Module?如何在 Prestashop 模块中初始化语言索引?
【发布时间】:2021-08-18 15:10:15
【问题描述】:

我正在尝试在 Prestashop 模块中创建一个新页面,因此我创建了一个控制器和一个视图。不幸的是,我收到了这个错误,但没有找到解决方案。 这是我的错误:

这是我的控制器:

<?php

require_once _PS_MODULE_DIR_.'opartdevis/models/OpartQuotation.php';

class OpartDevisAskTypeClientModuleFrontController extends ModuleFrontController
{
    public $auth = true;
    public $guestAllowed = true;
    

    public function init()
    {
        $this->display_column_left = false;
        $this->display_column_right = false;
        parent::init();
    }

    public function setMedia($isNewTheme = false)
    {
        parent::setMedia();

            $this->registerStylesheet(
                'opartdevis-style',
                'modules/'.$this->module->name.'/views/css/opartdevis.css'
            );
            $this->registerJavascript(
                'opartdevis-front',
                'modules/'.$this->module->name.'/views/js/front.js'
            );
            $this->registerJavascript(
                'opartdevis-tools',
                'js/tools.js'
            );
    }

    public function initContent() {
        $this->setTemplate('module:opartdevis/views/templates/front/ps17/asktype.tpl');
    }


    public function postProcess()
    {
        $type = Tools::getValue('typeClient');

       /**  return Tools::redirect(
           * $this->context->link->getModuleLink(
            *    'opartdevis',
             *   'createquotation',
              *  array(
               *     'create'=>true,
                *    'typeClient'=> $type
                *)
            *)
        *);*/

    }
}

这是我的看法:

{extends file='page.tpl'}

{block name="page_content"}
    {capture name=path}Ask your client type{/capture}
    <h1>Quel type d'utilisateur etes vous ?</h1>

        <form action="{$link->getModuleLink('opartdevis', 'askTypeClient')|escape:'htmlall':'UTF-8'}" method="post" class="form-horizontal" enctype="multipart/form-data" id="opartDevisForm">
            <p>Quel type d'utilisateur êtes vous ?</p>

            <div>
                <input type="radio" id="clientType" name="askType" value="clientType"
                        checked>
                <label for="clientType">Client</label>
            </div>

            <div>
                <input type="radio" id="providerType" name="askType" value="providerType">
                <label for="providerType">Provider</label>
            </div>

            <p class="cart_navigation">
                <a href="{$link->getPageLink('my-account', true)|escape:'htmlall':'UTF-8'}" class="btn btn-default button button-small">
                    <span><i class="icon-chevron-left"></i> {l s='Back to Your Account' mod='opartdevis'}</span>
                </a>
                <button type="submit" name="submitQuotation" id="submitQuotation" class="button btn btn-primary button-medium"><span>Submit</span></button>
            </p>
        </form>
{/block}

你能帮帮我吗?

我的代码结构基于另一个控制器,它可以在没有任何语言索引的情况下工作。

提前致谢

【问题讨论】:

    标签: php prestashop smarty


    【解决方案1】:

    试试

    public function initContent() {
            $this->context->smarty->assign(array(
                'language' => $this->context->language->id,
            ));
            $this->setTemplate('module:opartdevis/views/templates/front/ps17/asktype.tpl');
    }
    

    【讨论】:

    • 感谢您的帮助,但仍然无法正常工作:/同样的错误
    • 一模一样?错误出现在布局两列上。它可以在您的模块加载之前。无论如何,在我的回答中,它将是语言对象,而不是语言 ID。如果禁用模块,PS 是否正常工作?
    猜你喜欢
    • 2016-08-19
    • 1970-01-01
    • 1970-01-01
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2022-01-10
    相关资源
    最近更新 更多