douchi0638 2015-07-20 08:03
浏览 28
已采纳

PHP代码是什么意思? Magento的

I have a site with a Magento theme and i found this code 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>

Who is this in this code? My div?

getChildHtml('', true, true);

From what I found on the internet I realized that '' means all the kids a div (whose div?)

I do not understand what parameters are used boolean true true ... in helping them?

I found it on the internet getChildHtml method takes things from an XML file.Where can I find this file?

Can you give me explain with a simple example code please?

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • duanbi7247 2015-07-20 09:05
    关注

    $this in above code refers to current class(object).

    'getChildHtml' method renders a child block according to the block name or alias supplied in the argument.

    <?php echo $this->getChildHtml('',true,true) ?>
    
    • The first argument is the name or alias of a child block. If supplied, it returns the output of that child block. If this argument is not supplied or passed as a blank string, it renders all the child blocks specified in the layout.
    • The second argument $useCache is a Boolean which is by default true. If it is true, the block is cached if the block cache is enabled under the Caching settings in the admin panel. If it is false, the block is not cached even if block cache is enabled.
    • The third argument $sorted is also a Boolean which is by default false. If it is true, the child blocks are rendered according to the sorting order defined by before and after attributes.

    Example :

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

    In above example is added to the Magento layout XML in app/design/frontend/base/default/layout/page.xml

    This is how we create block in XML file :

    <block type="core/text_list" name="content" as="content" translate="label">
        <label>Main Content Area</label>
    </block>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口