model - From where, data comes to block in magento? -


in base\default\template\customer/account/navigation.phtml code is

<div class="block block-account"> <div class="block-title">     <strong><span><?php echo $this->__('my account'); ?></span></strong> </div> <div class="block-content">     <ul>         <?php $_links = $this->getlinks(); ?>         <?php $_index = 1; ?>         <?php $_count = count($_links); ?>         <?php foreach ($_links $_link): ?>             <?php $_last = ($_index++ >= $_count); ?>             <?php if ($this->isactive($_link)): ?>                 <li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getlabel() ?></strong></li>             <?php else: ?>                 <li<?php echo ($_last ? ' class="last"' : '') ?>><a href="<?php echo $_link->geturl() ?>"><?php echo $_link->getlabel() ?></a></li>             <?php endif; ?>         <?php endforeach; ?>     </ul> </div> 

it display following list :

account information

i know block, want know how block receive data , where.if link between block , model if how. 1 explain overall flow.

they come class, can find block type.

making search on magento template (view) state here customer/account/navigation.phtml find layout related it.

and can find block type.

so in customer.xml, can find :

<block type="customer/account_navigation" name="customer_account_navigation" template="customer/account/navigation.phtml"> 

and block type customer/account_navigation class mage_customer_block_account_navigation can find in file src/app/code/core/mage/customer/block/account/navigation.php

to find class, there quite complicated game of xml handles , path file mechanism explained multiple time already, if curious : meaning , location of string inside magento's mage:getsingleton , magento: call custom block in cms

the links there, looks after, are, can see, property of class itself, got filled in via :

public function addlink($name, $path, $label, $urlparams=array()) {     $this->_links[$name] = new varien_object(array(         'name' => $name,         'path' => $path,         'label' => $label,         'url' => $this->geturl($path, $urlparams),     ));     return $this; } 

and can see on layout call method add links block, e.g. in review.xml

<reference name="customer_account_navigation">     <action method="addlink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>my product reviews</label></action> </reference> 

you can see same block because name in reference node here same name defined block reproduced here above : customer_account_navigation.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -