久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

理解 Magento 中的 getChildHtml

Understanding getChildHtml in Magento(理解 Magento 中的 getChildHtml)
本文介紹了理解 Magento 中的 getChildHtml的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

從 2columns-right.phtml 中的以下行

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

我無法理解 <?php echo $this->getChildHtml('content') ?> 中的 content 來自哪里.

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

調用哪個.phtml文件來顯示數據

解決方案

如果我們正在討論網站的前端,那么您詢問的特定行....

getChildHtml('content') ?>

被添加到 app/design/frontend/base/default/layout/page.xml 中的 Magento 布局 XML 中.在 Magento 1.8 版中,您會發現它在第 92-94 行中定義.

<label>主要內容區</label>

通過查看這個block標簽的type"屬性,我們可以知道這部分布局是什么對象類.它來自核心"模塊,屬于塊類型文本列表.此 Mage_Core_Block_Text_List 的類名.(app/code/core/Mage/Core/Block/Text/List.php).文本列表只是塊容器,其目的是在其中存儲額外的子塊.您可以將任意數量的子塊添加到文本列表中,它們將按照添加順序或分配順序進行渲染.

因此,為了回答您的問題,沒有呈現 $this->getChildHtml('content') 內容的視圖腳本(.phtml 文件). 已經添加到這個塊,它們本身可能有與之關聯的視圖腳本.要找出那些是什么視圖腳本,您必須找到添加了塊的布局 XML.

例如,如果我將以下布局文件添加到我網站主題的前端:

<布局><默認><參考名稱=內容"><block type="core/template" name="my_view_script" template="hello/world.phtml"/></參考></默認></布局>

上面的代碼會將對象類為 Mage_Core_Block_Template 的塊添加到名為內容"的塊中(這恰好是您詢問的那個).然后 Magento 將在以下位置按順序查找視圖腳本:

app/design/frontend/PACKAGE_NAME/THEME_NAME/template/hello/world.phtmlapp/design/frontend/PACKAGE_NAME/default/template/hello/world.phtmlapp/design/frontend/base/default/template/hello/world.phtml

找到的第一個就是它將使用的那個.如果沒有找到視圖腳本,Magento 將在 var/logs/system.log(默認日志文件設置)中記錄一個錯誤,指出沒有找到視圖腳本.不會發生塊的輸出.

請注意,根據您在 System -> Configuration -> (General) Design 中的設置,Magento 可能會查看其他 package/theme 位置.還有其他情況,例如自定義主題"是針對單個 CMS 頁面、目錄類別或目錄產品更改的字段,這些單個模型的視圖頁面可能具有優先于您站點的默認設置的附加視圖腳本位置(將匹配所選主題).

Magento 在查找翻譯文件和布局 XML 文件時將遵循相同的回退邏輯.

請注意,從 app/design/frontend/base/default/template/app/design/frontend/base/default/template/ 到您的本地主題,并根據您網站的主題自定義它們.然而,為了有一個升級兼容的站點,布局文件不應該從基礎復制到你的本地主題.這樣做并不遵循升級兼容做法.相反,您的主題的 XML 布局更新應包含在 app/design/frontend/PACKAGE_NAME/THEME_NAME/layout/local.xml 中.app/design/frontend/base/default/layout/* 中沒有布局說明,無法刪除/添加/更改,您有什么,使用正確的 XML 說明本地.xml.

From the following line in 2columns-right.phtml

<div class="col-main">
    <?php echo $this->getChildHtml('global_messages') ?>
    <?php echo $this->getChildHtml('content') ?>
</div>

I am not able to understand where the content in <?php echo $this->getChildHtml('content') ?> is coming from.

Which .phtml file is called to display the data by <?php echo $this->getChildHtml('content') ?>?

解決方案

If we're discussing the frontend of the website, the particular line you've asked about....

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

is added to the Magento layout XML in app/design/frontend/base/default/layout/page.xml. In Magento version 1.8, you'll find it defined in lines 92-94.

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

By looking at the "type" attribute of this block tag, we can know what object class this section of the layout is. It comes from the "Core" module, and is of the block type Text List. The class name for this Mage_Core_Block_Text_List. (app/code/core/Mage/Core/Block/Text/List.php). Text Lists are simply block containers which purpose is to store additional child blocks inside them. You can add any number of child blocks to the text list and they will be rendered out either in the order they were added or the order they've been assigned.

So, to answer your question, there is no view script (.phtml file) that renders the contents of $this->getChildHtml('content'). The blocks which have been added to this block, may themselves have view scripts associated with them. To find out what view scripts those are, you'd have to find the layout XML which has added the block.

For example, if I had the following layout file added to the frontend of my website's theme:

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="content">
            <block type="core/template" name="my_view_script" template="hello/world.phtml" />
        </reference>
    </default>
</layout>

The code above, would add the block with an object class of Mage_Core_Block_Template to the block with the name 'content' (which happens to be the one you asked about). Magento will then look for the view script in the following locations, in this order:

app/design/frontend/PACKAGE_NAME/THEME_NAME/template/hello/world.phtml
app/design/frontend/PACKAGE_NAME/default/template/hello/world.phtml
app/design/frontend/base/default/template/hello/world.phtml

First one that is found, is the one it will use. If no view script is found Magento will log an error in var/logs/system.log (default log file setting) stating that the view script was not found. No output from the block will occur.

Note that depending on your settings in System -> Configuration -> (General) Design, there may be additional package/theme locations Magento will look in. There are also other scenarios such as if the "Custom Theme" is field is changed for individual CMS Pages, Catalog Categories, or Catalog Products, these individual model's view page may have an additional view script location (that will match the selected theme) that takes precedence over your site's default settings.

Magento will follow this same fallback logic when looking for translation files as well as layout XML files.

Please note, that it is perfectly acceptable to copy individual view scripts (avoid copying entire directories, copy over only view scripts you actually intend to modify) from app/design/frontend/base/default/template/ to your local theme, and customize them for the purposes of your website's theme. However, in order to have an upgrade compatible site, layout files should not be copied from base to your local theme. Doing so, does not follow upgrade compatible practices. Instead, XML Layout updates for your theme should be contained in app/design/frontend/PACKAGE_NAME/THEME_NAME/layout/local.xml. There is no layout instructions from app/design/frontend/base/default/layout/*, that cannot be removed/added-to/changed, what-have-you, with the proper XML instructions in local.xml.

這篇關于理解 Magento 中的 getChildHtml的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产一区二区三区视频免费观看 | 亚洲精品v| 日韩国产在线 | www.久久精品视频 | 精品国产91乱码一区二区三区 | 99re99| 国产va | 婷婷国产一区二区三区 | 激情一区二区三区 | 精品成人佐山爱一区二区 | 99精品视频在线观看免费播放 | av毛片免费 | 国产九九九 | 国产毛片久久久久久久久春天 | 日韩三级精品 | 99reav| 久久久国产一区二区三区四区小说 | av在线一区二区三区 | 欧美一区二区三区久久精品视 | 国产伦一区二区三区久久 | 精品99在线 | 无毛av | 在线中文视频 | 97成人在线 | 久久精品一区二 | 日本成人在线免费视频 | 日韩欧美在线一区 | 久草视频在 | 婷婷色国产偷v国产偷v小说 | 中文字幕一区二区在线观看 | 久久久久久久久久久一区二区 | 久久伊人青青草 | 国产一级视频在线播放 | 老头搡老女人毛片视频在线看 | www.一级毛片 | 国产精品日韩一区二区 | 福利视频网址 | 久久久久久天堂 | 91资源在线 | 国产欧美一区二区三区另类精品 | 欧美激情视频一区二区三区在线播放 |