Difference between revisions of "How do you put a module inside an article?"

From Joomla! Documentation

(Some markup changes.)
 
(37 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{JVer|1.5}} {{JVer|1.6}} {{JVer|1.7}} {{JVer|2.5}}
+
<noinclude><languages /></noinclude>
 +
<noinclude>{{Joomla version|version=2.5|time=and after|comment=<translate><!--T:1-->
 +
series</translate>}}</noinclude>
 +
<translate>
 +
<!--T:2-->
 +
You will usually want to associate modules with articles in some way. The modules are allocated to module positions and the module positions appear somewhere on the Web page as determined by the template.  However, it is sometimes useful to have a module actually embedded within the article. Joomla core provides three ways to do that: loadposition, loadmodule and loadmoduleid. The plugin "Content - Load Modules" must be enabled.
 +
</translate>
  
You will usually want to associate modules with articles in some way.  The modules are allocated to module positions and the module positions appear somewhere on the Web page as determined by the template.  However, it is sometimes useful to have a module actually embedded within the article.
+
<translate><!--T:3-->
 +
Syntax:</translate>
 +
*''{loadposition position[, style]}''
 +
*''{loadmodule mod_type,the title[, style]}''
 +
*''{loadmoduleid moduleId}''
  
To insert a module inside an article, use the ''{loadposition xx}'' command, as follows:
+
<translate>
#Create a module and set its position to any value that doesn't conflict with an existing template position. You can type in the position value instead of selecting it from the drop-down list. For example, use the position ''myposition''.
+
==loadposition== <!--T:4-->
#Assign the module to the Menu Items that contain the articles that you want the module to show in. You can also just assign the module to '''all''' Menu Items.
+
To insert a module inside an article, you publish the module to a position and load that position in the article as follows:
#Edit the articles where you want this module to appear and insert the text ''{loadposition myposition}'' in the article at the place where you want the module.
+
</translate>
  
Note that this only works when the [[Screen.plugins.edit.15#Content_-_Load_Module|''Content - Load Module'' plugin is enabled]]. If this plugin is disabled, the text ''{loadposition myposition}'' shows unchanged in the article.
+
<translate>
 +
<!--T:5-->
 +
#Create a module and set its position to '''''myposition'''''. '''''myposition''''' can be any value that doesn't conflict with an existing template position. Type in the position '''''myposition''''' and press enter instead of selecting it from the drop-down list.
 +
</translate>
 +
<translate>
 +
<!--T:6-->
 +
#Assign the module to '''All''' the Menu Items. This will make sure that it always appears, no matter how the visitor got to the article. The module will not show unless you put the command to load the module in an [[S:MyLanguage/article|article]].
 +
#Edit the articles where you want this module to appear and insert the text '''''{loadposition myposition}''''' in the article at the place where you want the module.
 +
</translate>
  
[[Category:FAQ]]
+
{{dablink|<translate><!--T:7-->
[[Category:Version 1.5 FAQ]]
+
Note that this only works when the [[S:MyLanguage/Help25:Extensions_Plugin_Manager_Edit#Content_-_Load_Modules|''Content - Load Module'' plugin is enabled]]. If this plugin is disabled, the text ''{loadposition myposition}'' shows unchanged in the article.
[[Category:Version 1.6 FAQ]]
+
 
[[Category:Version 1.7 FAQ]]
+
<!--T:8-->
[[Category:Version 2.5 FAQ]]
+
Also, the name of the position should be all lowercase. CamelCapitalization will fail.</translate>}}
[[Category:Administration FAQ]]
+
 
[[Category:Article Management]]
+
<translate>
[[Category:Module Management]]
+
==loadmodule== <!--T:9-->
 +
An alternative to ''{loadposition xx}'' is the ''{loadmodule yyy}'' variation which is handled by the same plugin.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:10-->
 +
In this case the plugin looks for the first module whose '''type''' matches the string ''yyy''. So you could load a "mod_login" module by placing {loadmodule login} in your text. If you wish to load a specific instance of a module, because you have more than one login module, e.g. titled as Login 1, Login 2, etc., you have to use {loadmodule mod_modType, modTitle} where mod_'''modType''' would be mod_login and '''modTitle''' is name/title given to your instance of that module. In the example above you end up with '''{loadmodule mod_login Login 2}'''. You can also add the style that is used for rendering the module. To do so, add the style as the third parameter like {loadmodule login,login2, xhtml}. If you don't add a style, then "none" is used.
 +
</translate>
 +
 
 +
<translate>
 +
==loadmoduleid== <!--T:18-->
 +
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.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:19-->
 +
In this case the plugin looks for the module whose ''id'' matches the number ''z''. You could load the module with id 200 by placing ''{loadmoduleid 200}'' in your text. This variant does not "understand" additional parameters such as the ''style'' parameter.
 +
</translate>
 +
 
 +
<translate>
 +
==Editor Button (Since Joomla! Version 3.5)== <!--T:20-->
 +
If the editors-xtd plugin ''Button - Module'' is enabled you can use the editor button ''Module'' to insert the above tags more easily. Since Joomla! 3.9 you can also use the editor button to insert the ''loadmoduleid'' variant.
 +
</translate>
 +
 
 +
<translate>==Modules Within Modules== <!--T:11--></translate>
 +
<translate>
 +
<!--T:12-->
 +
It is possible in Joomla! 2.5+ and Joomla! 3.x+ to include a module within a "Custom HTML" module. They are processed by content plugins in the same way as articles.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:13-->
 +
To make this work, the option ''Prepare Content'' must be enabled as shown in this screenshot.
 +
</translate>
 +
 
 +
[[File:j3x_custom_html_prepare_content_option-<translate><!--T:14-->
 +
en</translate>.png||<translate><!--T:15-->
 +
Showing the Prepare Content option in a Custom HTML module.</translate>]]
 +
 
 +
<translate>
 +
<!--T:16-->
 +
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 the "Module" editor button is not available in modules of type "Custom".
 +
</translate>
 +
 
 +
<noinclude>
 +
<translate>
 +
<!--T:17-->
 +
[[Category:Content Management FAQ]]
 +
[[Category:Article Management FAQ]]
 +
</translate>
 +
</noinclude>

Latest revision as of 17:09, 13 September 2022

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎português do Brasil • ‎中文(台灣)‎
Joomla! 
≥ 2.5
series

You will usually want to associate modules with articles in some way. The modules are allocated to module positions and the module positions appear somewhere on the Web page as determined by the template. However, it is sometimes useful to have a module actually embedded within the article. Joomla core provides three ways to do that: loadposition, loadmodule and loadmoduleid. The plugin "Content - Load Modules" must be enabled.

Syntax:

  • {loadposition position[, style]}
  • {loadmodule mod_type,the title[, style]}
  • {loadmoduleid moduleId}

loadposition[edit]

To insert a module inside an article, you publish the module to a position and load that position in the article as follows:

  1. Create a module and set its position to myposition. myposition can be any value that doesn't conflict with an existing template position. Type in the position myposition and press enter instead of selecting it from the drop-down list.
  2. Assign the module to All the Menu Items. This will make sure that it always appears, no matter how the visitor got to the article. The module will not show unless you put the command to load the module in an article.
  3. Edit the articles where you want this module to appear and insert the text {loadposition myposition} in the article at the place where you want the module.

loadmodule[edit]

An alternative to {loadposition xx} is the {loadmodule yyy} variation which is handled by the same plugin.

In this case the plugin looks for the first module whose type matches the string yyy. So you could load a "mod_login" module by placing {loadmodule login} in your text. If you wish to load a specific instance of a module, because you have more than one login module, e.g. titled as Login 1, Login 2, etc., you have to use {loadmodule mod_modType, modTitle} where mod_modType would be mod_login and modTitle is name/title given to your instance of that module. In the example above you end up with {loadmodule mod_login Login 2}. You can also add the style that is used for rendering the module. To do so, add the style as the third parameter like {loadmodule login,login2, xhtml}. If you don't add a style, then "none" is used.

loadmoduleid[edit]

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 whose id matches the number z. You could load the module with id 200 by placing {loadmoduleid 200} in your text. This variant does not "understand" additional parameters such as the style parameter.

Editor Button (Since Joomla! Version 3.5)[edit]

If the editors-xtd plugin Button - Module is enabled you can use the editor button Module to insert the above tags more easily. Since Joomla! 3.9 you can also use the editor button to insert the loadmoduleid variant.

Modules Within Modules[edit]

It is possible in Joomla! 2.5+ and Joomla! 3.x+ to include a module within a "Custom HTML" module. They are processed by content plugins in the same way as articles.

To make this work, the option Prepare Content must be enabled as shown in this screenshot.

Showing the Prepare Content option in a Custom HTML module.

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 the "Module" editor button is not available in modules of type "Custom".