Magento Layout.xml <remove ...> tag not having desired effect
I have a "auth-redirect" module that is in the beginning of all my page layout files (1column, 2column, etc). This works to make sure that before rendering any page, if the user is not authenticated properly then it redirects to a login page.
The way that I allow the login page to render is in my customer.xml file I declare the following:
<customer_account_login>
<remove name="auth-redirect"/>
...
</customer_account_login>
This works fabulously.
However I recently created another module custom module and when I go to the urls that engage that module's controller and render the modules layout the auth-redirect stays in the page and thus I always get redirected.
The custom module layout looks like this:
<shipment_management_index>
<remove name="auth-redirect"/>
<reference name="content">
<block type="custom/vendor_shipment_info" template="custom/vendor/shipment/info.phtml" name="info"/>
</reference>
</shipment_management_index>
Now, I've gone to the page and using Alan Storm's showLayout module gotten the output from ?showLayout=page. You can see that the element for auth-redirect is in the page, down below the body, but at the top auth-redirect is still in the page. What am I missing?
<layout><block name="formkey" type="core/template" template="core/formkey.phtml"/>
<block type="page/html" name="root" output="toHtml" template="page/1column.phtml">
<block type="page/html" name="auth-redirect" as="auth-redirect" template="page/html/auth-redirect.phtml" ignore="1"/>
<block type="page/html_head" name="head" as="head">
...
</block>
...
<remove name="auth-redirect"/>
<reference name="content">
<block type="custom/vendor_shipment_info" templat开发者_开发百科e="custom/vendor/shipment/info.phtml" name="info"/>
</reference>
</reference></layout>
Is your last piece of code in the same file ? If so, why not trying to comment/delete the first
<block type="page/html" name="auth-redirect" as="auth-redirect" template="page/html/auth-redirect.phtml" ignore="1"/>
If not, maybe the code below will work if the "auth-redirect" block you want to remove is nested into the "formkey" block.
<reference name="formkey">
<action method="unsetChild"><name>auth-redirect</name></action>
</reference>
精彩评论