0

In base\default\template\customer/account/navigation.phtml the 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 as $_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 the following list :

account information

i know the block, but i want to know how the block receive this data and from where.if any link between block and model if its how. any one explain this overall flow.

Naga
  • 21
  • 6
  • No model data is being passed to the Navigation block. Most of the functions are inherited from template block and the abstract class the template extends. – André Ferraz Feb 08 '16 at 15:38

1 Answers1

0

They actually come from a class, which is something you can find back thanks to the block type.

Making a search on my Magento with the template (view) you state here customer/account/navigation.phtml will help you find the layout related to it.

And then you can find the block type.

So in customer.xml, you can find :

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

And this block type customer/account_navigation is actually the class Mage_Customer_Block_Account_Navigation that you can find in the file src/app/code/core/Mage/Customer/Block/Account/Navigation.php

To find back this class, there is a quite complicated game of xml handles and path to file mechanism that I already explained multiple time already, if you are curious about it : meaning and location of string inside Magento's Mage:getSingleton and Magento: call a custom block in CMS

The links there, as it looks that is what you are after, are, as you can see, a property of the class itself, that 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 you can also see on some layout that they actually call this method to add links to that 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 also see that it is the same block because the name in the reference node here is the same as the name defined for this block as reproduced here above : customer_account_navigation.

Community
  • 1
  • 1
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • exactly correct brother. But i have a confusion from beginning that is, from the above template, we can see this line " getLinks(); ?> ". We know the getLinks() method is define in the "Navigation.php" file. The code is : public function getLinks() { return $this->_links; } but here i want to know about this line "return $this->_links;" here i returns what? and what this "$this->_links" refers or where it's come from – Naga Feb 09 '16 at 06:42
  • thanks brother. and i want an answer for an another question. the question link is [link](http://stackoverflow.com/questions/35293507/how-add-a-customer-reorders-as-a-link-on-toplinks). Sorrry to ask this here, because i dont know how to share this question with you. – Naga Feb 10 '16 at 05:39
  • @Naga, you can't share question here, Stack Overflow is not a forum, and please stop calling people "brother" :| – β.εηοιτ.βε Feb 11 '16 at 17:37