一个名为top.phtml的文件里所有的代码如下:<div class="menu">
<div class="menu2">
     <div class="indent">
            <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
            <ul id="nav">
            <?php foreach ($this->getStoreCategories() as $_category): ?>
            <?php echo $this->drawItem($_category) ?>
            <?php endforeach ?>
            </ul>
            <div class="clear"></div>
        </div>
</div>
</div>
我现在的疑惑是,该文件并没有包含任何其他目录下的css和php文件
1,class调用的是哪里文件的类型???
2,$this调用哪里的方法???它不是只能调用本类声明的方法??帮下忙,谢谢大家。

解决方案 »

  1.   

    当然能运行,这个是magento下的一个文件
    完整代码如下:
    <?php/**
     * templatemonster.com
     *
     * NOTICE OF LICENSE
     *
     * This source file is subject to the Open Software License (OSL 3.0)
     * that is bundled with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://opensource.org/licenses/osl-3.0.php
     *
     * @category   design_theme001
     * @package    TM
     * @copyright  Copyright (c) 2008 templatemonster.com (http://www.templatemonster.com)
     * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
     */?><?php /** * Top menu for store * * @see Mage_Catalog_Block_Navigation */?><div class="menu"> <div class="menu2">     <div class="indent">            <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>            <ul id="nav">            <?php foreach ($this->getStoreCategories() as $_category): ?>                                <?php echo $this->drawItem($_category) ?>                            <?php endforeach ?>            </ul>            <div class="clear"></div>        </div> </div></div>    <?php //echo $this->getChildHtml('topLeftLinks') ?>
      

  2.   

    包含他的文件是一个(.xml)文件下面是代码
    <reference name="top.menu">            <block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>        </reference>不明白,这样是怎么能调用到php代码里的方法的
    而且方法在哪个文件都没搞明白
      

  3.   

    是一个包含文件, phtml服务器根本解释不了,  他的程序或apache里肯定设置可以把phtml代替php文件来运行,  就这个文件来说, 根本无法运行, 看代码就很明确, 明显是一个菜单导航之类的, 这种东西, 肯定是作为模块被调用, 或包含的. lz说的class, $this , 单独来说是毫无意义的, 就像这模板中的语法 <? endforeach ?> 
      

  4.   

    to 4楼xml就是被php调用的  不是它调用php,或php里的方法
      

  5.   

    回楼上,按照你的说法
    流程是不是这样:
    php调用--》xml-->再执行xml所包含的phtml文件调用的程序使用$this的解释就是:$this其实就是调用的php里的类方法是这样的吧???
      

  6.   

    请问一下怎么用以下代码查看phtml这个文件的$this属于哪的类
    echo print_r(get_class_methods(get_class( $this )));
    没法运行phtml文件阿。没法下手了
      

  7.   

    to 11楼
    $this不是这个类的对象名,echo print_r(get_class_methods(get_class( $this )))这个代码肯定运行不了的,
    源码不全无法解释