Jdoc statements: Difference between revisions

From Joomla! Documentation

MATsxm (talk | contribs)
mNo edit summary
Yuhoward (talk | contribs)
No edit summary
Line 2: Line 2:
<translate>
<translate>
<!--T:45-->
<!--T:45-->
jdoc statements are included in every Joomla [[S:MyLanguage/Template|template]] and indicate where the output from other parts of Joomla or its extensions should be positioned in the overall web page.  A typical jdoc statement looks like this: <code><jdoc:include type="component" /></code>
jdoc 聲明會包含在每一個 Joomla [[S:MyLanguage/Template|template]]裡,並會指出 Joomla 的其他部分要顯示在哪裡或是該擴展元件會顯示於整個網頁中。一個標準的 jdoc 聲明看起來就像這樣:<code><jdoc:include type="component" /></code>
</translate>
</translate>
<translate>== jdoc:include == <!--T:23--></translate>
<translate>== jdoc:include == <!--T:23--></translate>
<translate><!--T:24-->
<translate><!--T:24-->
The <code><jdoc:include /></code> statement is a Joomla! template's method of displaying content specific to the page being viewed. There are various <code><jdoc:include /></code> statements, each returning a different part of a Joomla! page. The replacement itself is done in JDocumentHTML::_renderTemplate. See also _parseTemplate.</translate>
<code><jdoc:include /></code> 聲明是 Joomla 佈景主題裡,用來指定網頁中要顯示的內容。以下有幾種 <code><jdoc:include /></code> 聲明,每一種都用來負責不同類型的內容輸出。該替換是在 JDocumentHTML::_renderTemplate 中完成的,另見 _parseTemplate。</translate>


<translate>=== The type attribute === <!--T:25--></translate>
<translate>=== 類型屬性 === <!--T:25--></translate>
<translate><!--T:26-->
<translate><!--T:26-->
The <tt>type</tt> attribute specifies the type of content to be rendered in place of the <code><jdoc:include /></code> element. For example, the <code><jdoc:include '''''type="head"''''' /></code> statement uses the <code>type</code> attribute <code>head</code> (<code>type="head"</code>). (''Note: Jdoc expressions require double quotes around attributes, and won't work with single quotes. The space before the closing /> is also mandatory''.)</translate>
<tt>類型</tt>屬性會在 <code><jdoc:include /></code> 元素中產生要顯示的內容類型。例如,<code><jdoc:include '''''type="head"''''' /></code> 聲明就使用了 <code>類型</code> 屬性 <code>head</code> (<code>type="head"</code>). (''注意:jdoc 表達式要求使用雙引號來包住屬性,如果使用單引號將會無任何作用,另外也必須在關閉符號 /> 之前加入一個半形空白'')</translate>


<translate>==== Component ==== <!--T:27--></translate>
<translate>==== 元件 ==== <!--T:27--></translate>
<source lang="html4strict">
<source lang="html4strict">
<jdoc:include type="component" />
<jdoc:include type="component" />
Line 18: Line 18:


<translate><!--T:28-->
<translate><!--T:28-->
This element should only appear once in the <body> element of the Template to render the main content of the page with respect to the current page being viewed.</translate>
此元素只能在佈景主題中的 <body> 裡出現一次,以便呈現目前瀏覽頁面中的主要內容。</translate>


<translate>==== Head ==== <!--T:29--></translate>
<translate>==== 頁頭 ==== <!--T:29--></translate>
<source lang="html4strict">
<source lang="html4strict">
<jdoc:include type="head" />
<jdoc:include type="head" />
Line 26: Line 26:


<translate><!--T:30-->
<translate><!--T:30-->
This element should only appear once in the <head> element of the Template to render the content of the style, script and meta elements associated with the current page.</translate>
此元素只能在佈景主題中的 <head> 裡出現一次,以便產生目前頁面中要使用的CSS樣式、script 以及 meta 元素等。</translate>


<translate>==== Installation ==== <!--T:31--></translate>
<translate>==== Installation ==== <!--T:31--></translate>

Revision as of 08:06, 10 November 2017

jdoc 聲明會包含在每一個 Joomla 的template裡,並會指出 Joomla 的其他部分要顯示在哪裡或是該擴展元件會顯示於整個網頁中。一個標準的 jdoc 聲明看起來就像這樣:<jdoc:include type="component" />

jdoc:include

<jdoc:include /> 聲明是 Joomla 佈景主題裡,用來指定網頁中要顯示的內容。以下有幾種 <jdoc:include /> 聲明,每一種都用來負責不同類型的內容輸出。該替換是在 JDocumentHTML::_renderTemplate 中完成的,另見 _parseTemplate。

類型屬性

類型屬性會在 <jdoc:include /> 元素中產生要顯示的內容類型。例如,<jdoc:include type="head" /> 聲明就使用了 類型 屬性 head (type="head"). (注意:jdoc 表達式要求使用雙引號來包住屬性,如果使用單引號將會無任何作用,另外也必須在關閉符號 /> 之前加入一個半形空白。)

元件

<jdoc:include type="component" />

此元素只能在佈景主題中的 <body> 裡出現一次,以便呈現目前瀏覽頁面中的主要內容。

頁頭

<jdoc:include type="head" />

此元素只能在佈景主題中的 <head> 裡出現一次,以便產生目前頁面中要使用的CSS樣式、script 以及 meta 元素等。

Installation

<jdoc:include type="installation" />

This element is only used within the Joomla! Installer template for Joomla Joomla 2.5 and below and is of no particular use in a Front-end or Back-end template. It's somewhat the equivalent to the 'component' type, rendering the main content of an installation step.

Message

<jdoc:include type="message" />

This element should only appear once in the <body> element of the Template to render system and error messages that occurred in the request.

CSS styles for system messages can be found in templates\system\css\system.css

Module

<jdoc:include type="module" name="breadcrumbs" title="Breadcrumbs" />
<jdoc:include type="module" name="mainmenu" title="Main Menu" />

This element renders a single module given by the name and title attributes: name should match module type (mod_breadcrumbs and mod_menu in the examples above) while title should be the module name of the desired module. The module in question must be published and accessible by the current user in order to become visible. Additional attributes can be provided to control the layout and appearance of the module, if supported.

Modules

Modules are rendered on a page using one of the following code examples. The modules are separated into different areas of a template using template positions set in the templatedetails.xml file. Using the jdoc:include's name="[template position name]" attribute, the various modules in their respective positions can be called, rendered, and styled separately. Additional attributes can be provided to control the layout and appearance of modules, if supported.

Below are some examples of module statements with module positions used frequently by Joomla! theme developers.

<jdoc:include type="modules" name="debug" />
<jdoc:include type="modules" name="icon" />
<jdoc:include type="modules" name="left" style="rounded" />
<jdoc:include type="modules" name="left" style="xhtml" />
<jdoc:include type="modules" name="right" style="xhtml" />
<jdoc:include type="modules" name="status"  />
<jdoc:include type="modules" name="syndicate" />
<jdoc:include type="modules" name="title" />
<jdoc:include type="modules" name="toolbar" />
<jdoc:include type="modules" name="top" />
<jdoc:include type="modules" name="top" style="xhtml" />
<jdoc:include type="modules" name="user1" style="xhtml" />
<jdoc:include type="modules" name="user2" style="xhtml" />
<jdoc:include type="modules" name="user3" />
<jdoc:include type="modules" name="user4" />

Note: The name="user3" module position is normally (by default) used for the top menu.

The style attribute

The optional style="" attribute is available for the module and modules types of <jdoc:include /> statements. The attribute value refers to the chrome style used to wrap the output generated by the Module. If no style is provided, a value of "none" is used by default.

Template designers may add additional chrome names as described in Applying custom module chrome.

See also