在magento中,数据从何处到达块?

在magento中,数据从何处到达块?,magento,model,block,Magento,Model,Block,在base\default\template\customer/account/navigation.phtml中,代码为 <div class="block block-account"> <div class="block-title"> <strong><span><?php echo $this->__('My Account'); ?></span></strong> </div&g

在base\default\template\customer/account/navigation.phtml中,代码为

<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>


    >

它将显示以下列表:


我知道块,但我想知道块是如何接收数据的,以及从何处接收数据的。如果块和模型之间有任何链接,如果它是如何接收的。任何人都可以解释这个整体流程。

它们实际上来自一个类,由于块类型,您可以找到这个类

使用您在此处声明的模板(视图)搜索my Magento
customer/account/navigation.phtml
将帮助您找到与其相关的布局

然后可以找到块类型

因此,在
customer.xml
中,您可以找到:

<block type="customer/account_navigation" name="customer_account_navigation" template="customer/account/navigation.phtml">
您还可以在一些布局上看到,他们实际上调用此方法来添加指向该块的链接,例如在
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>

回顾回顾/客户我的产品回顾

您还可以看到它是同一个块,因为此处引用节点中的名称与上面为该块定义的名称相同:
customer\u account\u navigation

没有模型数据传递到导航块。大多数函数都继承自模板块和模板扩展的抽象类。完全正确。但我从一开始就感到困惑,也就是说,从上面的模板中,我们可以看到这一行“”。我们知道getLinks()方法是在“Navigation.php”文件中定义的。代码是:公共函数getLinks(){return$this->\u links;}但是这里我想知道关于这行“return$this->\u links;”这里我返回什么?还有这个“$this->\u links”指的是什么,或者它来自哪里。我想回答另一个问题。问题链接是。很抱歉在这里问这个问题,因为我不知道如何和你们分享这个问题。@Naga,你们不能在这里分享这个问题,Stack Overflow不是一个论坛,请不要叫别人“兄弟”:|
<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>