Никак не могу добавить свойства в .tpl

Автор murd0c, 15 января 2015, 01:55:20

« назад - далее »

murd0c

попробовал и так: в модуле-> productcomments.php public function hookDisplayProductListReviews($params)
{   $smarty->assign("features",$features);
require_once(dirname(__FILE__).'/ProductComment.php');
$smarty->assign("features",$features);
$average = ProductComment::getAverageGrade((int)$params['product']['id_product']);
$this->smarty->assign(array(
   'product' => $params['product'],
   'averageTotal' => round($average['grade']),
   'nbComments' => (int)(ProductComment::getCommentNumber((int)$params['product']['id_product']))
  ));
return $this->display(__FILE__, 'productcomments_reviews.tpl');
}



а в тпл, которая в темах <!-- Fancybox -->
<div style="display: none;">
<div id="new_comment_form">
<form id="id_new_comment_form" action="#">
<h2 class="title">НапишиС,Рµ РЎРІРѕР№ РћС,зыв</h2>
{if isset($product) && $product}
<div class="product clearfix">
<img src="{$link->getImageLink($product->link_rewrite, $productcomment_cover, 'home_default')|escape:'html'}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product->name|escape:html:'UTF-8'}" />
<div class="product_desc">
<p class="product_name"><strong>{$product->name}</strong></p>



{if isset($features) && $features}
<!-- product's features -->
<ul>

{foreach from=$features item=feature}
                {if isset($feature.value)}
<li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>
                {/if}
{/foreach}
</ul>
{/if}





</div>
</div>
{/if}



Никак(

PrestaMan

Не видно определение переменной $features в productcomments.php. Что вы передаете в шаблон? Где инициализация переменной $features?
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!

murd0c

хм, а как это сделать? я даже не програмист и половины слов не понимаю, помогите новичку)

Виталий

#18
Цитироватьу меня есть товар и у него есть свойства (features) мне надо его вставить в комментарии-туда, когда нажимаешь на кнопку оставить свои коментарии вместо короткого описания ({$product->description_short}) ! как мне это сделать??

Уточните, что вы хотите сделать.
1. Вы хотите на стрнице товара поменять вывод описания товара. Заменить вывод краткого описания на вывод свойств товара?
2. Или вы хотите показать свойства товара во всплывающем окне комметариев товара?
Cоздание интернет сайтов Webstudio UwK

murd0c

вот так хочу, а сейчас вместо высоты и тд у меня короткое описание

Adik

Цитата: Adik от 22 января 2015, 14:31:51
Поэтому вам нужно добавить В productcomments.php переменную для шаблона

$this->context->smarty->assign(array(
'logged' => $this->context->customer->isLogged(true),
'action_url' => '',
'product' => $product,
...................
'features' => $product->getFrontFeatures($this->context->language->id),
));

murd0c

#21
 в productcomments.php public function hookProductTabContent($params)
{
$this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js');
$this->context->controller->addJS($this->_path.'js/jquery.textareaCounter.plugin.js');
$this->context->controller->addJS($this->_path.'js/productcomments.js');

$id_guest = (!$id_customer = (int)$this->context->cookie->id_customer) ? (int)$this->context->cookie->id_guest : false;
$customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)$this->context->cookie->id_customer, true, (int)$id_guest);

$averages = ProductComment::getAveragesByProduct((int)Tools::getValue('id_product'), $this->context->language->id);
$averageTotal = 0;
foreach ($averages as $average)
$averageTotal += (float)($average);
$averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0;

$image = Product::getCover((int)Tools::getValue('id_product'));

$this->context->smarty->assign(array(
'logged' => $this->context->customer->isLogged(true),
'action_url' => '',
'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, $this->context->cookie->id_customer),
'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id),
'averages' => $averages,
'product_comment_path' => $this->_path,
'averageTotal' => $averageTotal,
'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'),
'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()),
'delay' => Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME'),
'id_product_comment_form' => (int)Tools::getValue('id_product'),
'secure_key' => $this->secure_key,
'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
'nbComments' => (int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')),
'productcomments_controller_url' => $this->context->link->getModuleLink('productcomments'),
'productcomments_url_rewriting_activated' => Configuration::get('PS_REWRITING_SETTINGS', 0),
'moderation_active' => (int)Configuration::get('PRODUCT_COMMENTS_MODERATE'),
'features' => $product->getFrontFeatures($this->context->language->id)

   ));
белый экран(

Adik

Значит где-то ошибка. Код рабочий, я проверил.

murd0c

#23
Это я вставил в productcomments.php, а код только в productcomment.tpl, которая в темах, правильно?

А не могли бы вы скинуть свой, полностью рабочий код? mrleonsvet@gmailточкаcom спасибо
я больше ничего нигде не менял..где мб еще ошибка?


Я делаю все так: открываю modules/productcomments/productcomments.php (там есть еще productcomment.php, и в public function hookProductTabContent($params)
...
$this->context->smarty->assign(array(
...

вставляю 'features' => $product->getFrontFeatures($this->context->language->id),, затем бегу в themes/.../modules/productcomments/prod...ts.tpl и вставляю в фанси бокс {if isset($features) && $features}
<!-- product's features -->
<ul id="idTab2" class="bullet">
{foreach from=$features item=feature}
                {if isset($feature.value)}
<li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>
                {/if}
{/foreach}
</ul>
{/if}

сохраняю, перебрасываю, должно работать, правильно? или что то забыл или не там, и с "$smarty->assign("features",$features);" что делать?




DarinSr

Цитироватьи с "$smarty->assign("features",$features);" что делать?
Ничего. Это не нужно использовать. Вы уже определили эту переменную. Вот этот код
features' => $product->getFrontFeatures($this->context->language->id)
Это вы уже сделали. Больше ничего не добавляте.

Цитироватьзатем бегу в themes/.../modules/productcomments/prod...ts.tpl и вставляю в фанси бокс
Да. Все правильно.

murd0c

не получается опять:( в чем может быть ошибка?

murd0c


PrestaMan

Цитата: Adik от 24 января 2015, 17:18:27
$this->context->smarty->assign(array(
'logged' => $this->context->customer->isLogged(true),
'action_url' => '',
'product' => $product,
...................
'features' => $product->getFrontFeatures($this->context->language->id),
));

Это самый простой путь. Определили переменную в модуле и можете ее использовать в шаблоне.
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!

murd0c

ребят, проверьте пожалуйста.. пишу как надо, вроде бы, и белый экран(

Adik

Там не чего проверять. Скопировали код и вставили его в файлы. Если даже это не получается, то лучше создайте тему в разделе работа и наймите программиста.