簡體   English   中英

為什么比功能強大的聰明人行不通?

[英]Why smarty greater than function doesn't work?

我試圖從網上商店的“添加到購物車”按鈕中插入以下代碼來替換CSS樣式,因此當產品為0時需要顯示“訂單”,而產品大於1時需要顯示“添加到”購物車”,但類.hideen(大於> =)不起作用,而另一個則不能。

{if $product->quantity <= 0}
<style type="text/css">
{literal}
.hideeen {display:none;}
{/literal}
</style>
{/if}
{if $product->quantity >= 1}
<style type="text/css">
{literal}
.hideen {display:none;}
{/literal}
</style>
{/if}

您可以在其中看到HTML的應用位置:

<button type="submit" name="Submit" class="exclusive">
<span class="btn">
{if $content_only && (isset($product->customization_required) && $product->customization_required)}<em>{l s='Customize'}</em>{else}<em class="hideeen">{l s='Add to cart'}</em>{/if}<em class"hideen">{l s='order'}</em>
</span>
</button>

在HTML上,缺少= there <em class"hideen">{ls='order'}</em>

Smarty使用某種xml解析器,因此代碼應為有效xml。
大於標志制動xml結構。

最好的解決方案是使用lt / gt函數:

{if $product->quantity gt 1}  

另一個選項可以是:

  • <![CDATA[]]>標記包裝此部分。
  • 使用反轉條件: 1 <= $q

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM