Pergunta

Gostaria de adicionar bloco de login somente se o cliente não estiver logado.Então, na minha página cms.xml eu mudo esse código

<reference name="content">
        <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
        <block type="page/html_wrapper" name="cms.wrapper" translate="label">
            <label>CMS Content Wrapper</label>
            <action method="setElementClass"><value>std</value></action>
            <block type="cms/page" name="cms_page"/>
        </block>
    </reference>

este é o meu código

<?xml version="1.0"?>

<default>
    <reference name="footer">
        <block type="cms/block" name="cms_footer_links" before="footer_links">
            <!--
                The content of this block is taken from the database by its block_id.
                You can manage it in admin CMS -> Static Blocks
            -->
            <action method="setBlockId"><block_id>footer_links_company</block_id></action>
        </block>
        <block type="cms/block" name="cms_footer_links_sm" after="footer_links2">
            <!--
                The content of this block is taken from the database by its block_id.
                You can manage it in admin CMS -> Static Blocks
            -->
            <action method="setBlockId"><block_id>footer_links_sm</block_id></action>
        </block>
    </reference>
</default>

<cms_menu>
    <reference name="left_first">
        <block type="cms/block" name="cms_menu" >
            <action method="setBlockId"><block_id>cms_menu</block_id></action>
        </block>
    </reference>
</cms_menu>

<cms_page translate="label">
    <label>CMS Pages (All)</label>
    <remove name="left.permanent.callout"/>

    <update handle="cms_menu"/>

   <reference name="content">
    <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
    <block type="page/html_wrapper" name="cms.wrapper" translate="label">
        <label>CMS Content Wrapper</label>
        <action method="setElementClass"><value>std</value></action>
        <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
        <block type="cms/page" name="cms_page"/>
    </block>
</reference>
    <customer_logged_in>
        <reference name="content">
                <remove  name="customer_form_login" />
        </reference>
    </customer_logged_in>



</cms_page>

<cms_index_index translate="label">
    <label>CMS Home Page</label>
</cms_index_index>

<cms_index_defaultindex>
    <remove name="right"/>
    <remove name="left"/>

    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="default_home_page" template="cms/default/home.phtml"/>
    </reference>
</cms_index_defaultindex>

<cms_index_noroute translate="label">
    <label>CMS No-Route Page</label>
</cms_index_noroute>

<cms_index_defaultnoroute>
    <remove name="right"/>
    <remove name="left"/>

    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="default_no_route" template="cms/default/no-route.phtml"/>
    </reference>
</cms_index_defaultnoroute>

Na minha lógica, isso significa que se o cliente estiver logado, o formulário de login será removido, mas na verdade será removido em todos os casos.O que está errado?

Foi útil?

Solução

Presumo que seu código xml seja inválido, você adicionou seu customer_logged_in dentro do seu cms_page referência

Deveria estar fora cms_page tente como abaixo:

<cms_page translate="label">
    <label>CMS Pages (All)</label>
    <reference name="content">
        <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
        <block type="page/html_wrapper" name="cms.wrapper" translate="label">
            <label>CMS Content Wrapper</label>
            <action method="setElementClass"><value>std</value></action>
            <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
            <block type="cms/page" name="cms_page"/>
        </block>
    </reference>
</cms_page>


<customer_logged_in>
    <reference name="content">
        <remove  name="customer_form_login" />
    </reference>
</customer_logged_in>

Ou você pode encontrar customer_logged_in em customer.xml arquivo de layout e adicione o código de remoção de bloco nesse arquivo.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top