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

  • SEARCH
  • Home
  • 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 7690375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:22:52+00:00 2026-05-31T20:22:52+00:00

I’m trying to set a variable in my local.xml file for my custom block:

  • 0

I’m trying to set a variable in my local.xml file for my custom block:

<layout>
    <!-- ... -->
    <page_homepage>
        <!-- ... -->
        <reference name="root">    
            <!-- ... -->
            <block type="core/template" name="home_page_sections" template="page/homepage/sections.phtml">
                <block type="layout/carousel" name="featured_carousel">
                    <action method="setData">
                        <name>filter_attribute</name>
                        <value>is_featured_product</value>
                    </action>
                </block>
            </block>
        </reference>
    </page_homepage>
</layout>

But I am not getting the data on the other end in my controller:

class Foo_Layout_Block_Carousel extends Mage_Core_Block_Template
{
    public function __construct() 
    {
        parent::__construct();

        $filterAttribute = $this->getFilterAttribute(); // Nothing
        $filterAttribute = $this->getData('filter_attribute'); // Nada

        // Alright, fine, what DO I have?!
        var_dump($this->getData()); // array(0) {} ... Argh!
    }
}

From all my searching I’ve found that this really should work, but since it does not, I have a feeling I’m missing something obvious. Here is my layout module’s configuration (I’m using a single module to define a homepage and any other blocks I need for the site):

<?xml version="1.0"?>
<config>
    <modules>
        <Foo_Layout>
            <version>0.1.0</version>
        </Foo_Layout>
    </modules>
    <global>
        <page>
            <layouts>
                <foo_homepage translate="label">
                    <label>Homepage</label>
                    <template>page/homepage.phtml</template>
                    <layout_handle>page_homepage</layout_handle>
                </foo_homepage>
            </layouts>
        </page>
        <blocks>
            <layout>
                <class>Foo_Layout_Block</class>
            </layout>
        </blocks>
    </global>
</config>
  • 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-31T20:22:53+00:00Added an answer on May 31, 2026 at 8:22 pm

    When the layout rendering code encounters this

    <block type="layout/carousel" name="featured_carousel">
    

    It immediately instantiates the block. That means the block’s __construct method is called before your setData method is called. So, at the time of construction, no data has been set, which is why your calls to var_dump return an empty array.

    Also, immediately after being created, the block is added to the layout

    #File: app/code/core/Mage/Core/Model/Layout.php
    ...
    $block->setLayout($this);
    ...
    

    When this happens, the block’s _prepareLayout method is called.

    #File: app/code/core/Mage/Core/Block/Abstract.php
    public function setLayout(Mage_Core_Model_Layout $layout)
    {
        $this->_layout = $layout;
        Mage::dispatchEvent('core_block_abstract_prepare_layout_before', array('block' => $this));
        $this->_prepareLayout();
        Mage::dispatchEvent('core_block_abstract_prepare_layout_after', array('block' => $this));
        return $this;
    }
    

    So, this means that any data set in your layout update xml is still not available, even in _prepareLayout. Once the system is done creating the block, it moves on to the next XML node.

    <action method="setData">
        <name>filter_attribute</name>
        <value>is_featured_product</value>
    </action>
    

    and calls the setData method. Now your block has its data set.

    Try defining a _beforeToHtml method on your block and checking for data there. (Assuming your block is being rendered)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported

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.