Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
text_list
 
Aaron Carlino
Jr. Member
 
Total Posts:  2
Joined:  2008-07-22
 

A lot of page elements are given the type “core/text_list.” There is no module called text_list as far as I can see. In page.xml, for instance, if you look in the header block, there’s a topMenu block of type “core/text_list.” If I wanted to make an update to this HTML, I have to go to catalog/navigation/top.phtml. How does Magento know to look there? I just found it accidentally.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Johan Akesson
Jr. Member
 
Total Posts:  3
Joined:  2009-03-19
 

Would also like to know this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Periculi
Sr. Member
 
Total Posts:  249
Joined:  2009-02-03
 

The block is located in magento/app/code/core/mage/core/block/text/list.php.  In the xml you can find where the block is called, for instance in page.xml there is a call for the core/text_list block in the header as “top.menu” which you will find is declared in catalog.xml, and pointed to the html template top.phtml.  In other xml pages you can find where the list is populated, for instance in customer.xml where the link My Account is added to top.links, which makes it part of the prepared list for top.menu.  But core/text_list actually serves more purposes than just simple list preparation. It is a generic loader for content blocks.

For more clarity, you can see that the left, right and content blocks in page.xml seem to also call the use of this block.  It doesn’t seem to be preparing a list, so perhaps it doesn’t do much?  Removing the reference in page.xml removes the content placed in the block, so it looks like it really is doing something important after all.  What I see there is that the text_list block sets up the empty container for the content blocks.  So by saying <block type="core/text_list" name="right" as="right"/> what you are doing there is preparing a container, in this case ‘right’ to add other content blocks to.  I think at that point the text_list declaration also is letting magento know that there are going to be further declarations to look for, by name for that block, i.e. ‘left’, ‘right’, or ‘content’.

Looking at List.php, we can see this happening-

class Mage_Core_Block_Text_List extends Mage_Core_Block_Text
{
    
protected function _toHtml()
    
{
        $this
->setText('');
        foreach (
$this->getSortedChildren() as $name{
            $block 
$this->getLayout()->getBlock($name);
            if (!
$block{
                Mage
::throwException(Mage::helper('core')->__('Invalid block: %s'$name));
            
}
            $this
->addText($block->toHtml());
        
}
        
return parent::_toHtml();
    
}
}

Pretty much says “Go get each of the blocks for this block or throw an error if a block doesn’t exist as named”.  Hope that helps.

 Signature 

...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Johan Akesson
Jr. Member
 
Total Posts:  3
Joined:  2009-03-19
 

Thanks Periculi, that clears up the text_list type! The reason I was looking into this was because I needed to know where the actual content for “top.menu” was defined, which is indeed as you point out in catalog.xml.

For a beginner like me it’s tricky to decode page.xml when it prints out stuff that is defined in other layout files. It’s like a forward declaration in C I guess… In the future I will try searching for the name attribute in all the layout files smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
bluescrubbie
Jr. Member
 
Total Posts:  21
Joined:  2009-10-01
 

Gee.  The lack of documentation for Magento is just absurd… nearly every sentence of Periculi’s response above brought up more questions than it answered.

>> The block is located in magento/app/code/core/mage/core/block/text/list.php.

As far as I can tell, core/text-list deconstructs to core/block/list/text.php.  That is, replace / with /block/, and subsequent hyphens with /.

>> In the xml you can find where the block is called, for instance in page.xml there is a call for the core/text_list block in the header as “top.menu” which you will find is declared in catalog.xml, and pointed to the html template top.phtml.

Is the only way to find such references by wading through directory trees?

>> In other xml pages you can find where the list is populated, for instance in customer.xml where the link My Account is added to top.links, which makes it part of the prepared list for top.menu.

Is there a way to deduce that it’s a list getting populated, or that adding a link to the top.links reference in customer.xml will make it part of the top.menu list defined in catalog.xml and called in page.xml?  Or is this reverse-engineering knowledge?

>> But core/text_list actually serves more purposes than just simple list preparation. It is a generic loader for content blocks.

Is this documented anywhere?  The most involved discussion on Google seems to be this thread.

>> For more clarity, you can see that the left, right and content blocks in page.xml seem to also call the use of this block.  It doesn’t seem to be preparing a list…

How would one determine if it’s preparing a list or not?

>>...so perhaps it doesn’t do much?  Removing the reference in page.xml removes the content placed in the block, so it looks like it really is doing something important after all.  What I see there is that the text_list block sets up the empty container for the content blocks.  So by saying <block type="core/text_list" name="right" as="right"/> what you are doing there is preparing a container, in this case ‘right’ to add other content blocks to.  I think at that point the text_list declaration also is letting magento know that there are going to be further declarations to look for, by name for that block, i.e. ‘left’, ‘right’, or ‘content’.

Dear Varien:  Magento’s layout model is quite complex, and by design, not linearly deconstructable.  (it’s like traversing a singly linked list backwards - you have to search every node for one that points to you).  That said, little things, like code comments, or a basic, concise map of the major default components would be quite simple to implement, and enormously simpler than hundreds of developers painstakingly desconstructing your model.

That is to say, Scavenger Hunts are great party games, but suck as a means of documentation.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2012 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
704132 users|1731 users currently online|497378 forum posts