Jdoc 聲明

From Joomla! Documentation

This page is a translated version of the page Jdoc statements and the translation is 79% complete.

Other languages:
English • ‎español • ‎فارسی • ‎français • ‎Bahasa Indonesia • ‎Nederlands • ‎русский • ‎中文(台灣)‎

jdoc 聲明會包含在每個 Joomla 的佈景主題中,並指定 Joomla 的部分或其它套件應該放置於整個網頁中的哪個位置。一個標準的 jdoc 聲明應該要像這樣:<jdoc:include type="component" />

jdoc:include

<jdoc:include /> 聲明是 Joomla! 佈景主題用來指定目前瀏覽的頁面中要如何顯示內容的一種方法。在此有各種不同的 <jdoc:include /> 聲明,每種都會在 Joomla! 頁面中導出不同的部分。至於替換本身則是在 JDocumentHTML::_renderTemplate 中完成。另見 _parseTemplate。

類型屬性

type 屬性是用來指定 <jdoc:include /> 元素中要使用的類型。例如,<jdoc:include type="head" /> 聲明使用了 type 屬性為 headtype="head")。(注意:Jdoc 的寫法要求使用雙引號來包住屬性,如果錯誤地使用了單引號將無法正常作用。例外在最後面使用 /> 時前面要先加一個半形空白才能完整關閉整句語法。)

元件

<jdoc:include type="component" />

此元素只會在佈景主題的 <body> 中出現一次而已,它是用來呈現目前瀏覽頁面中的主要內容。

頁頭

<jdoc:include type="head" />

此元素只會在佈景主題的 <head> 中出現一次而已,它是用來產生目前瀏覽頁面中所指定使用的 CSS 樣式、JavaScript腳本以及 meta 元素等。

安裝

<jdoc:include type="installation" />

此元素只會使用於 Joomla Joomla 2.5 與之後版本的 Joomla! 安裝佈景主題,且在前台與後台佈景主題中沒有特定的用途。其實它有點等同於 '元件' 類型了,它會在安裝步驟中呈現主要內容。

訊息

<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 樣式可以至此路徑找到: templates\system\css\system.css

模組

<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 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" />

'註記:name="user3"的模組位置通常(預設值)會被使用在上方選單。

樣式屬性

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.

另請參考