我想检查产品是否有特定标签。如果是这样,我想显示一些文字。以下是我所做的一些示例。有用。唯一的问题是我得到错误。检查产品是否在Prestashop中有特定标签1.6.1.4
{if in_array('rent', $product->tags.1)}
<img id="turnKeyimg" alt="TurnKey Rental Option" src="{$tpl_uri}img/key.png"/>
<h3>TurnKey Rental Option</h3>
<p>Also available for immediate rental.<br />Request a quote today</p>
{/if}
错误日志有这样的条目:
警告:in_array()预计参数2为阵列,在/cache/smarty/compile/94/4d/52/944d5284e871d0de7a0c6b84ebb2089ad579ed8b.file空给出.product.tpl.php在高速缓存行330
线330看起来是这样的:
<?php if (in_array('rent',$_smarty_tpl->tpl_vars['product']->value->tags[1])) {?>
<img id="turnKeyimg" alt="TurnKey Rental Option"
src="<?php echo $_smarty_tpl->tpl_vars['tpl_uri']->value;
?>
我做了什么错了导致这些错误?
这个用smarty怎么看?我不能使用<?php。 我试过了:{if(is_array($ _ smarty_tpl-> tpl_vars ['product'] - > value-> tags [1])&& in_array('rent',$ _ smarty_tpl-> tpl_vars ['product'] - > value - > tags [1]))}但该检查不再有效。我查看了一个标签出租的产品,我想要显示的文本没有显示。 – N13Design
@ N13Design我不是Smarty模板的专家,但是您是否尝试了这种方法,[https://pastebin.com/ZBy4eNJe](https://pastebin.com/ZBy4eNJe)? –
Prestashop里面有些东西不喜欢。它打破了页面。 – N13Design