在我的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>
会显示选项卡+框
所以我需要知道:
- 为什么我登录时没有显示
- 当我登录时,我可以做这个节目吗?但只能在特定的客户群中
我想也许你可以用<customer_logged_in setCustomerGroupId="2">
或类似的东西!
谢谢。
您可以使用客户登录重定向magento扩展。它会解决你的问题。
别担心,我现在已经通过.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;?>