且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento直接链接到产品选项卡

更新时间:2023-11-30 16:05:16

不幸的是,没有一些编码.这些选项卡是ul列表中的元素.您可以做的是一个JavaScript代码段,该代码段检查给定的请求参数并触发特定选项卡链接上的click事件.

Unfortunately not without some coding. The tabs are li-elements in a ul-list. What you could do is a javascript snippet that checks for a given request parameter and trigger a click event on the particular tab link.

这是现代主题演示商店的一部分:

This is a part of the modern theme demo store:

<ul class="product-tabs"> 
                    <li id="product_tabs_description" class=" active first"><a href="#">Product Description</a></li> 
                            <li id="product_tabs_upsell_products" class=""><a href="#">We Also Recommend</a></li> 
                            <li id="product_tabs_additional" class=""><a href="#">Additional Information</a></li> 
                                        <li id="product_tabs_product.tags" class=" last"><a href="#">Product Tags</a></li> 
        </ul> 

...,然后Chrome检查工具将显示带有以下内容的第一个标签页眉:

...and the Chrome inspection tool will show the first tab header with:

<a href="javascript:void(0)">Product Description</a>

...将运行以下代码:

...that will run this code:

initTab: function(el) {
  el.href = 'javascript:void(0)';
  if ($(el.parentNode).hasClassName('active')) {
    this.showContent(el);
  }
  el.observe('click', this.showContent.bind(this, el));

},

因此,我将通过在Javascript中查找request参数并触发该li-元素链接的click事件来解决该问题.

So, I would solve it by looking for the request parameter in a Javascript and the trigger a click event for that li-element link.