[英]changing attributes of product view in magento
I have a section of extra information for the product. 我有一部分有关该产品的额外信息。 In the config you can add a link.
在配置中,您可以添加链接。 This is showing the text of the link, but we want to have a word as a link and not the url to be seen.
这是显示链接的文本,但是我们希望有一个单词作为链接,而不是要显示的url。
For the product additional information there is now 1 working link. 对于产品的其他信息,现在有1个工作链接。 (a word that is the link instead of showing the url)
(一个单词,而不是显示链接的链接)
Now for a second field (second link) , I want to do the same. 现在,对于第二个字段(第二个链接) ,我想做同样的事情。 When this field is filled with an url, the word "second link " must be the link, but not showing the url.
当此字段填充有URL时,单词“ second link ”必须是链接,但不显示该URL。 The word "second link" is the link
单词“第二个链接”是链接
I tried to change the attributes.phtml but I get lost changing the php code. 我试图更改attributes.phtml,但丢失了更改php代码的迷路。
<?php foreach ($_additional as $_data): ?>
<tr class="<?php if ($_data['value'] == "No" or $_data['value']== "Nee" or $_data['value'] == "N/A" or $_data['value'] == "Nvt" ){?>no-data-value<?php } ?>">
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data">
<?php if($_data['code'] == 'link'){?>
<a href="<?php echo $_data['value']?>"target="_blank" class="link-manufacturer"><?php echo $this->__('Product page manufacturer')?></a>
<?php }else{?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
I am trying to do the same for the second field. 我正在尝试对第二个领域做同样的事情。 How do I change this in the php?
如何在php中更改此设置? I tried several things but ends up in a loop showing it twice or i get an error in the syntax.
我尝试了几件事,但最终循环显示两次,否则语法错误。
You may try the code below: 您可以尝试以下代码:
<?php
$links = array('link' => 'Product page manufacturer',
'YOUR_CODE_OF_SECOND_LINK' => 'TEXT_FOR_SECOND_LINK');
foreach ($_additional as $_data): ?>
<tr class="<?php if ($_data['value'] == "No" or $_data['value']== "Nee" or $_data['value'] == "N/A" or $_data['value'] == "Nvt" ){?>no-data-value<?php } ?>">
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data">
<?php if(array_key_exists($_data['code'], $links)){
$code = $_data['code']; ?>
<a href="<?php echo $_data['value']?>"target="_blank" class="link-manufacturer"><?php echo $this->__($links[$code])?></a>
<?php }else{?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
You will be able to add links' codes and texts to the $links array. 您将能够将链接的代码和文本添加到$ links数组中。 It's not very good to edit template files by this way, but it should work.
用这种方法编辑模板文件不是很好,但是应该可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.