Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6341881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:07:46+00:00 2026-05-24T20:07:46+00:00

Is there a way to conditionally add a block in my magento layout based

  • 0

Is there a way to conditionally add a block in my magento layout based on whether the current customer is part of a group or not?

or would this be something better handled in the controller?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:07:47+00:00Added an answer on May 24, 2026 at 8:07 pm

    It would be nice to use something like customer_logged_in and customer_logged_out but sadly that doesn’t exist… yet.

    Let’s copy the same technique. To start with you’ll need to make a module with this in the config:

    <frontend>
        <events>
            <controller_action_layout_load_before>
                <observers>
                    <customer_group_observer>
                        <class>CUSTOM_MODULE/observer</class>
                        <method>beforeLoadLayout</method>
                    </customer_group_observer>
                </observers>
            </controller_action_layout_load_before>
        </events>
    </frontend>
    

    In the CUSTOM_MODULE_Model_Observer class add this method:

    public function beforeLoadLayout($observer)
    {
        $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
        $group = Mage::getModel('customer/group')->load($groupId);
    
        $observer->getEvent()->getLayout()->getUpdate()
           ->addHandle('customer_group_'.$group->getCode());
    }
    

    Now in layout files you can use the customer groups.

    <layout>
        <customer_group_General>
            <reference name="content">
                <!-- Add some blocks -->
            </reference>
        </customer_group_General>
    </layout>
    

    Additionally, this method doesn’t let you directly specify blocks per page but you can work around that. Here is an example that creates a new location for product pages only, on all other pages the update should have no effect and fail gracefully.

    <layout>
        <catalog_product_view>
            <reference name="content">
                <block type="core/text_list" name="group_container" />
            </reference>
        </catalog_product_view>
    
        <customer_group_General>
            <reference name="group_container">
                <!-- Add some blocks -->
            </reference>
        </customer_group_General>
    </layout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to conditionally ( based on report parameter for example )
Is there a way to conditionally load different user control as edit form based
Is there a way to conditionally embed resources into a .NET project? I.e. if
I was wondering if there is a way to conditionally compile entire namespaces in
Is there any way to do something conditionally in jquery only if IE6 is
Is there a way to dynamically and conditionally create a class definition in PHP,
Is there an analogous conditional-not-present attribute or maybe a way to use the Conditional
I'm wondering if there is a way to add a conditional break point in
Is there any way to use conditional statements in CSS?
Is there a way to do a conditional insert in the compact edition? I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.