0

在我的 Magento 产品页面上,我有一个选项卡式系统来显示描述、功能和另一个名为“下载”的选项卡 - 这需要对特定组中的登录客户可见。

在我的 catalog.xml 的布局 XML 中,我有这个:

<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
     <action method="addToParentGroup"><group>detailed_info</group></action>
     <action method="setTitle"><name>Description</name></action>
</block>

<block type="catalog/product_view_description" name="product.features" as="features" template="catalog/product/view/features.phtml">
    <action method="addToParentGroup"><group>detailed_info</group></action>
    <action method="setTitle"><name>Features</name></action>
</block>

<customer_logged_in>
    <block type="core/template" name="product.downloads" as="downloads" template="catalog/product/view/downloads.phtml">
        <action method="addToParentGroup"><group>detailed_info</group></action>
        <action method="setTitle"><name>Downloads</name></action>
    </block>           
</customer_logged_in> 

但是——即使我以任何组中的客户身份登录,该框也不会显示,因此<customer_logged_in>从那里删除会显示选项卡 + 框。

所以我需要知道:

  1. 为什么我登录时不显示?
  2. 我可以在登录后进行此节目吗?但只能在特定客户群中进行?

我想也许你可以使用<customer_logged_in setCustomerGroupId="2">或类似的东西!

谢谢。

4

2 回答 2

2

您可以使用客户登录重定向 magento 扩展。它将解决您的问题。

于 2012-07-25T11:22:36.770 回答
1

别担心,我现在已经通过 .phtml 模板文件进行了排序,下面的代码供其他人使用:

$_allowed_group_ids = array(1); // Stick in Allowed Customer Group ID's
$_product_collateral = array(); // We will store the tabbed content in our own array
$_restricted_tabs = array('downloads');

foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html) {

    $_product_collateral[$alias] = $html;   

    if( in_array($alias, $_restricted_tabs) ):              

        if( Mage::getSingleton('customer/session')->isLoggedIn() ):

            $_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();

            if( !in_array($_group_id, $_allowed_group_ids) ):                           
                unset($_product_collateral[$alias]);
                continue;
            endif;
        else:
            unset($_product_collateral[$alias]);
            continue;                           
        endif;      

    endif;                                                                      
}

示例用法:

<ul>
    <?php foreach( $_product_collateral as $alias => $html ): ?>
    <li><a href="#tab-<?php echo strtolower($alias); ?>"><?php echo ucfirst($alias); ?></a></li>
    <?php endforeach; ?>    
</ul>

框内容的示例用法:

<?php foreach( $_product_collateral as $alias => $html ): ?>            
<div class="box-collateral <?php echo "box-{$alias}"?>" id="tab-<?php echo strtolower($alias); ?>">
    <?php echo $html; ?>
</div> 
<?php endforeach;?>
于 2012-07-25T13:20:14.787 回答