检查配置值是否为空无效

时间:2015-04-07 17:01:50

标签: xml magento php

我正在尝试检查产品页面的view.phtml文件中的配置值是否为空。这是view.phtml中的代码:

<?php if (!empty($_config['size_chart_attribute_identifier'])):?>
    <a href="#size_chart" id="size_chart_link" class="fancybox">
        <?php echo $this->__('size chart') ?>
    </a>
    <div style="display:none">
        <div id="size_chart">
            <?php $cmsstatic = $_product->getResource()->getAttribute('size_chart')->getFrontend()->getValue($_product); 
            echo $this->getLayout()->createBlock('cms/block')->setBlockID($cmsstatic)->tohtml();?>
        </div>
    </div>
<?php endif;?>

我的config.xml文件部分如下:

<meigee_blacknwhite_productpage>
            <general>
                <collateral_related>related_slider</collateral_related>
                <relatedposition>bottom</relatedposition>
                <moreviews>moreviews_slider</moreviews>
                <moreviews_hover>0</moreviews_hover>
                <prevnext>prevnext</prevnext>
                <product_sku>1</product_sku>
                <productimg>zoom</productimg>
            </general>
            <layout>
                <collateral>collateral_tabs</collateral>
                <productsidebar>right</productsidebar>
                <pagelayout>productpage_large</pagelayout>
                <collateral_position>underdetails</collateral_position>
            </layout>
            <brand>
                <productbrand>1</productbrand>
                <brandformat>.png</brandformat>
                <brandsearch>1</brandsearch>
                <brandtarget>1</brandtarget>
                <brandpos>sidebar</brandpos>
            </brand>
<size_chart_attribute_identifier></size_chart_attribute_identifier>
            <additional>
                <product_custom>blacknwhite_product_custom</product_custom>
                <product_related_content></product_related_content>
            </additional>
            <rich_snippets>
                <status>1</status>
                <breadcrumbs>1</breadcrumbs>
                <product_ratings>1</product_ratings>
                <product_price>1</product_price>
                <product_availability>1</product_availability>
            </rich_snippets>
        </meigee_blacknwhite_productpage>

和system.xml部分如下所示:

<size_chart_attribute_identifier translate="label">
    <label>Size chart attribute identifier</label>
    <frontend_type>text</frontend_type>
    <sort_order>45</sort_order>
    <comment>
    <![CDATA[If you wish to display link to size chart, enter the attribute identifier here. Empty to disable. <a href="https://www.shopshark.net/knowledgebase/article/257/how-to-create-size-charts/" target="_blank">More info</a>.]]>
    </comment>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
 </size_chart_attribute_identifier>

在管理面板中,我可以输入我想要的值并保存(它可以正确保存)。

但是在加载产品页面时,即使文本已保存到管理员中的size_chart_attribute_identifier,也不会显示任何内容。

我也试过回复$_config['size_chart_attribute_identifier']并且没有返回任何内容。如果我拿走if语句,代码就会正常显示。但我需要if语句..

0 个答案:

没有答案
相关问题