PHP代码是什么意思?线上购物


What does it mean PHP code? Magento

我有一个Magento主题的网站,我发现这个代码PHP。

<div class="product-options sss" id="product-options-wrapper">
    <?php echo $this->getChildHtml('', true, true);?>                    
    <?php if ($this->hasRequiredOptions()):?>
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
    <?php endif;?>
</div>

谁是这段代码中的this ?我的div吗?

getChildHtml('', true, true);

从我发现在互联网上我意识到''的意思是所有的孩子一个div(谁的div?)

我不明白什么参数是使用布尔true true…帮助他们?

我发现它在互联网上getChildHtml方法从XML文件中获取东西。我在哪里可以找到这个文件?

你能给我解释一个简单的例子代码吗?

提前感谢!

$this在上面的代码中是指当前的类(对象)。

' getChildHtml '方法根据参数中提供的块名或别名呈现子块。

<?php echo $this->getChildHtml('',true,true) ?>
  • 第一个参数是子块的名称或别名。如果提供,则返回该子块的输出。如果没有提供此参数或以空字符串的形式传递,它将呈现布局中指定的所有子块。
  • 第二个参数$useCache是一个布尔值,默认为true。如果为真,则如果在管理面板的缓存设置下启用了块缓存,则块将被缓存。如果为false,则即使启用了块缓存,也不会缓存该块。
  • 第三个参数$sorted也是默认的布尔值假的。如果为真,则子块将根据排序顺序由前后属性定义。

例子:

<?php echo $this->getChildHtml('content') ?>

在上面的例子中被添加到Magento布局XML app/design/frontend/base/default/layout/page.xml

这是我们在XML文件中创建块的方法:

<block type="core/text_list" name="content" as="content" translate="label">
    <label>Main Content Area</label>
</block>

周围的HTML代码是客户端。内部PHP代码位于服务器端。$this指的是当前正在执行的类函数,在本例中是Magento模板控制器。

您可以在这里查看使用Magento模板开发的示例:http://code.tutsplus.com/articles/magento-theme-development-template-files--cms-21040