

<textarea>HTML標籤來裝載你輸入的Product attribute,而HTML會無視textarea的換行符\n,所以店面顯示的Product attribute沒有換行。
解決辦法:將\n轉為HTML換行標籤<br />;或用不會忽略\n的HTML標籤來裝載Product attribute。
以下方法適用於Opencart v1.5.1.3
foreach ($product_attribute_query->rows as $product_attribute) {
$product_attribute_data[] = array(
'attribute_id' => $product_attribute['attribute_id'],
'name' => $product_attribute['name'],
'text' => $product_attribute['text']
);
}
$product_attribute['text']更改為nl2br($product_attribute['text'])。nl2br()是PHP函數,會在\n之前插入HTML換行標籤<br /> 。
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php } ?>
<td><?php echo $attribute['text']; ?></td>修改為<td><pre><?php echo $attribute['text']; ?></pre></td>。<pre>會保留文本中的空格和換行符號。
.attribute tbody tr td { white-space: pre-wrap; }
white-space: pre-wrap;會保留其套用文本中的空格和換行符號。
我在Opencart後台輸入Product的attribute時有換行,但店面顯示的卻沒有換行,怎麼辦?
我們熱心幫助無叉用的人

0 comments:
Post a Comment