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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘