如何將模組放到文章裡?
From Joomla! Documentation
你通常會希望用某種方法把模組放到某個文章裡。模組是被分配到模組位置,然後模組位置在網頁的哪個地方是由模板來定義的。但是不管怎樣,有時候把模組放到文章裡是很方便的。Joomla 的核心允許兩個方法可以做到這個:loadposition 和 loadmodule。
語法:
- {loadposition position,[style]}
- {loadmodule mod_type,the title,[style]}
- {loadmoduleid moduleId}
loadposition
要把模組放進一個文章裡,你比需把模組設置到一個模組位置,並且將模組位置放進文章裡:
- 新增一個模組並且將它設置到myposition模組位置中。myposition 可以是任何一個不與現有的模板衝突的位置。在模組位置中輸入myposition 然後按下 ENTER ,而不要在下拉式選單中選取。
- 將模組分配到 All 的選單項目中。這樣可以確保它一直都會被使用,不用擔心訪客是用什麼方式造訪你的文章的。但是這樣子模組還是不會出現,除非你在 文章 中讀取它。
- 編輯你希望顯示模組的文章,並且在內容裡,將 {loadposition myposition} 插入到你希望模組出現的地方。
還有,模組位置的名稱必須是全部小寫。
CamelCapitalization 會失效。loadmodule
"{loadposition xx}" 的另一個選項是 "{loadmodule yyy}",差別在於有些外掛的處理方式。
在這個情況下,外掛會先檢查哪個模組的 類型 是字串'yyy'。所以你可以讀取一個用 {loadmodule login} 在文章裡讀取的 "mod_login" 模組。如果你有超過一個 login module,名為 login1、login2、等等,而你希望讀取某個特定的已創建模組,你必須使用 {loadmodule login,login2},而模組名稱是 login2。你也可以新增一個樣式,它將會在顯示模組的時候被使用,新增樣式需要傳遞第三個參數,例如:{loadmodule login,login2,xhtml}。如果你不新增樣式的話,它將會以"none"為指數。
loadmoduleid
Since Joomla! version 3.9.0 an alternative to {loadposition xx}
and {loadmodule yyy}
is the variation {loadmoduleid z}
which is handled by the same plugin.
In this case the plugin looks for the module who's id
matches the number z
. So you could load the module with id 200 by placing {loadmoduleid 200}
in your text. This variant does not "understand" additional parameters like the style
parameter.
Editor Button (since Joomla! version 3.5)
If the editor-xtd plugin "Button - Module" is activated you can use the editor button "Module" to insert above described tags more easily into the editor text. Since Joomla! 3.9 also the loadmouleid
variant.
===模組裡面的模組===
在 Joomla! 2.5+ 和 Joomla! 3.x+ 中有辦法將一個模組插入到一個 "自訂 HTML" 模組中,而它會被處理內容的外掛以和文章同樣的方式來被進行處理。
要讓它生效, 在截圖中的 Prepare content 選項必須是啟用的。
You should remember when doing this that you might experience formatting issues as the "chrome" of the "Custom HTML" module will surround the "chrome" of the included module potential having undesirable effects of the formatting or layout. That's the reason why the "Module" editor button is not available in modules of type "Custom".