• No se han encontrado resultados

DETERMINACIÓN DEL PUNTO DE EQUILIBRIO

6. ESTUDIO FINANCIERO

6.5. DETERMINACIÓN DEL PUNTO DE EQUILIBRIO

As previously mentioned, when we call the

generateXml

method on the layout

1. Combines all the chunks of Update XML into a single tree by concatenat-

ing them under a top level

<layout>

node

2. Does some additional processing of the nodes

3. Sets this new tree as the Layout’s XML. In other words, set it as the Page

Layout

So, in our examples above, that means we end up with a Page Layout that looks

something like this

< layout > <! - - u p d a t e l o a d e d f r o m p a g e . xml - - > < b l o c k t y p e = " n o f r i l l s _ b o o k l a y o u t / t e m p l a t e " n a m e = " r o o t " t e m p l a t e = " simple - p a g e /2 col . p h t m l " o u t p u t = " t o H t m l " > < b l o c k t y p e = " n o f r i l l s _ b o o k l a y o u t / t e m p l a t e " n a m e = " a d d i t i o n a l _ h e a d " t e m p l a t e = " simple - p a g e / h e a d . p h t m l " / > < b l o c k t y p e = " n o f r i l l s _ b o o k l a y o u t / t e m p l a t e " n a m e = " s i d e b a r " > < a c t i o n m e t h o d = " s e t T e m p l a t e " > < t e m p l a t e > simple - p a g e / s i d e b a r . phtml </ t e m p l a t e > </ action > </ block > < b l o c k t y p e = " c o r e / t e x t _ l i s t " n a m e = " c o n t e n t " / > </ block > <! - - u p d a t e l o a d e d f r o m n o f r i l l s _ b o o k l a y o u t _ r e f e r e n c e _ f o x . xml - - > < r e f e r e n c e n a m e = " c o n t e n t " > < b l o c k t y p e = " c o r e / t e x t " n a m e = " o u r _ m e s s a g e " > < a c t i o n m e t h o d = " s e t T e x t " > < text > M a g e n t o is a f o x y s y s t e m . </ text > </ action > </ block > </ r e f e r e n c e > </ layout >

The step we haven’t covered yet is #2

Do some additional processing of the nodes

After concatenating all the updates into a single XML tree, but before assigning

that tree as the Page Layout XML, Magento will process the concatenated

tree for additional directives. As of Community Edition 1.4.2, the only other

directive supported is

<remove/>

.

Let’s give the remove directive a try. Alter your

nofrills booklayout reference fox.xml

to include a

<remove/>

tag, as below.

< r e f e r e n c e n a m e = " c o n t e n t " > < b l o c k t y p e = " c o r e / t e x t " n a m e = " o u r _ m e s s a g e " > < a c t i o n m e t h o d = " s e t T e x t " > < text > S i d e b a r ? We don ’ t n e e d a s i d e b a r ! </ text > </ action > </ block > </ r e f e r e n c e >

< r e m o v e n a m e =" s i d e b a r " / >

Reload your URL

h t t p :// m a g e n t o . e x a m p l e . c o m / n o f r i l l s _ b o o k l a y o u t / r e f e r e n c e / f o x

and you should see a pagewithout

the block named sidebar, which was ren-

dering our navigation.

2.11.1

Before (Figure 2.3)

Figure 2.3

2.11.2

After (Figure 2.4)

Remove instructions are processed in the

Mage Core Model Layout::generateXml

method.

This method

1. Combines all updates with a call to

$xml = $this->getUpdate()->asSimplexml();

2. Looks through the combined updates for any nodes named

remove

.

3. If it finds a

remove

node, it then takes that node’s name and looks for any

block

or

references

nodes with the same name.

4. If it finds any

blocks

or

references

, these nodes are marked with an

ignore

Figure 2.4

5. The

remove

blocks are ignored during the Layout rendering process. Their

job is to mark which nodes should be ignored. After that, they’re irrelevant

Once the remove instructions have been processed, the resulting tree is set as

the Page Layout.

This means in our most recent example we ended up with a Page Layout XML

tree that looked exactly the same as before, with one exception

< b l o c k t y p e = " n o f r i l l s _ b o o k l a y o u t / t e m p l a t e " n a m e = " s i d e b a r " i g n o r e = " 1 " >

When a

<block/>

or

<reference/>

has an

ignore="1"

attribute node, the Layout

rendering process willskipthat block. In this way, the block, and all its sub-

blocks, are removed from the final rendered page.

Documento similar