#php #prestashop #smarty
Вопрос:
Я пытаюсь создать новую страницу в модуле 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}
Не могли бы вы мне помочь, пожалуйста ?
Я основал структуру своего кода на другом контроллере, и он работает без какой-либо строки о языковом индексе.
Заранее спасибо
Ответ №1:
Попробуй
public function initContent() {
$this->context->smarty->assign(array(
'language' => $this->context->language->id,
));
$this->setTemplate('module:opartdevis/views/templates/front/ps17/asktype.tpl');
}
Комментарии:
1. Спасибо за вашу помощь, но она все равно не работает :/ С той же ошибкой
2. Точно такой же? Ошибка в макете-в обоих столбцах. Это может быть до загрузки вашего модуля. В любом случае в моем ответе это будет объект языка, а не идентификатор языка. Если вы отключите свой модуль, правильно ли работает PS?