the joomla load module plugin

20
© 2005-2013 New Life in IT Pty Ltd - Visit learn.theartofjoomla.com to learn more about Joomla! This tutorial covers the Joomla Load Module plugin. It explains how to use the {loadposition} and {loadmodule} tags, and their variations, to embed modules directly in your site content (for example, in an article). It is applicable for Joomla 1.5, Joomla 2.5 and Joomla 3. The Joomla Load Module Plugin

Upload: andrew-eddie

Post on 05-Dec-2014

19.559 views

Category:

Technology


2 download

DESCRIPTION

This tutorial covers the Joomla Load Module plugin. It explains how to use the {loadposition} and {loadmodule} tags, and their variations, to embed modules directly in your site content (for example, in an article). It is applicable for Joomla 1.5, Joomla 2.5 and Joomla 3.

TRANSCRIPT

Page 1: The Joomla Load Module Plugin

© 2005-2013 New Life in IT Pty Ltd - Visit learn.theartofjoomla.com to learn more about Joomla!

This tutorial covers the Joomla Load Module plugin. It explains how to use the {loadposition} and {loadmodule} tags, and their variations, to embed modules directly in your site content (for example, in an article). It is applicable for Joomla 1.5, Joomla 2.5 and Joomla 3.

The Joomla Load Module Plugin

Page 2: The Joomla Load Module Plugin

Configuring the Load Module Plugin

Page 3: The Joomla Load Module Plugin

The easiest way to find the Load Module plugin is to go to the Plugin Manager in the Joomla administrator (it’s under “Extensions” in the top menu) and change the “Select Type” filter to “content”.

Tip

If you don’t actually need to embed modules or module positions in your content, it is a good idea to disable this plugin. Disabling any content plugin that you don’t really need will give you a small performance boost.

Also note that in Joomla 2.5 and Joomla 3, when Smart Search is used (Finder), content plugins are turned off to index the content.

Page 4: The Joomla Load Module Plugin

Load Module Plugin Options

The Load Module plugin has the option to set the style by which the module will display. The options correspond to the following modules styles in the template:Wrapped by table (column) - tableWrapped by table (horizontal) - horizWrapped by Divs - xhtmlWrapped by Multiple Divs - roundedNo wrapping - none

“Wrapped by Divs” or “No wrapping” would be the most common selections.

Note that in Joomla 1.5, there is an additional option called “Enable Plugin”. If the Load Module plugin was enabled, but this option was set to “No”, then any matching plugin tags, like {loadposition}, would be stripped from the content. Note also that the {loadmodule} tag is not available in Joomla 1.5.

In Joomla 2.5 and Joomla 3, this option does not exist. If the Load Module plugin is disabled, any usage of {loadposition} or {loadmodule} in the body content will appear unchanged on the site.

Page 5: The Joomla Load Module Plugin

Using {loadposition} in Content

Page 6: The Joomla Load Module Plugin

Option 1 - Loading a Module Position

The Load Module plugin allows you to enter:

{loadposition module_position}

within your content. This will embed all the modules configured to display in “module_position” according to the rules that you set in the administrator’s Module Manager.

In the example, the tag will embed any modules assigned to the “saythanks” module position in the content. The module style will be what you set in the options of the Load Module position.

Most editors will place the plugin call within paragraph tags.

This may suit your needs but if it doesn’t, change your editor to view the source and change the enclosing paragraph tags to div tags.

You may also want to add a class to the div for additional styling. A ‘clearfix’ div may also be desirable depending on how you configure or display the modules in the selected position.

Page 7: The Joomla Load Module Plugin

Option 2 - Loading a Position with a Style

In Joomla 2.5 and Joomla 3, you can also override the module style by entering:

{loadposition module_position,style}

where the style is added after the module position, separated by a comma.

Limitations

When using more than one {loadposition} tag within the same content for the same position, the module style will be fixed after the first use. This is because the Load Module plugin caches the modules in a given position.

However, this would be a very rare case (probably only used by people trying to write tutorials about how to use the Load Module position).

Page 8: The Joomla Load Module Plugin

Next, you need to add the module you want to display. Here I’m adding a simple Custom HTML module to display a link to my Amazon wish list.

The position needs to be set to whatever was used in the {loadposition} call in the content. You may or may not want to show the title of the module (particularly when using the “xhtml” style).

The text of the module can be filled out as desired and the module assignment needs to be configured (“On all pages” is the easiest).

Page 9: The Joomla Load Module Plugin

The images to the left show the final product.

The top image shows the standard usage of {loadposition}. In this case, the module style that was set in the plugin is used (and in this case, that was “No wrapping” or “raw” in template speak). Notice with this style, the module title will never be displayed.

The bottom image shows how {loadposition} can override the style set in the plugin. In this case, the “xhtml” style is set. You can see this because the title is showing. You can, of course, toggle the title from the Module Manager using this particular module style.

Page 10: The Joomla Load Module Plugin

Using {loadmodule} in Content

Page 11: The Joomla Load Module Plugin

Option 1 - Loading a Default Module

In Joomla 2.5 and Joomla 3, a second tag, {loadmodule}, was added to the Load Module plugin. As its name suggests, instead of loading a position containing any number of modules, it just loads a single instance of a module.

The tag is written in the form of:

{loadmodule module}

where “module” is the name of the folder the module resides in. The example shows how to include a plain Login module in your content.

Page 12: The Joomla Load Module Plugin

The {loadmodule mod_login} tag is replaced with a plain Login module.

Limitations

Because you are just setting the module type, there is no information associated with the module. No title will be available for the module and any options that the module requires will use the default values set in the module code itself.

Unless the module is extremely simple, it is often better to specify a module that you have configured in the Module Manager. See the next slide for how to do that.

Page 13: The Joomla Load Module Plugin

Option 2 - Loading a Module by Title

You can also load a specific module from the module by supplying its title after the module type in the form:

{loadmodule module,title}

where “title” is the title you gave the module in the Module Manager.

Caution

The module type and the title must match exactly. If you have more than one module of the same type with the same name, the results could be unpredictable (Joomla will probably display the first one it finds by the order it was added to the database).

Page 14: The Joomla Load Module Plugin

The tag has been replaced with the instance of the “Amazon Wishlist” module that I created in the Module Manager.

Note that the module style is whatever was set as the default in the Load Module plugin (in this case “No Wrapping” or “raw”).

Limitations

You can only use one type of module on the same page, regardless of where the content is. As for “loadposition”, the module is cached against its type, not its title.

Page 15: The Joomla Load Module Plugin

Option 3 - Loading a Module by Title

Finally, you can also a specific module from the Module Manager with a specific style by supplying the style after the module type and title in the form:

{loadmodule module,title,style}

where “style” is the desired module style.

Page 16: The Joomla Load Module Plugin

The tag has been replaced with the instance of the “Amazon Wishlist” module and displayed in the “xhtml” style so that that title will display.

Page 17: The Joomla Load Module Plugin

In Joomla 1.5, the type of module would be displayed in the “Type” column in the Module Manager or in the “Module” column of the Extension Manager.

Unfortunately, for our purposes, Joomla 2.5 and Joomla 3 translate the module type into readable text. The next slide lists the core modules in Joomla 2.5 and Joomla 3.

Core Modules Types

Page 18: The Joomla Load Module Plugin

Frontend Modules Types in Joomla 2.5 and 3mod_articles_archivemod_articles_categoriesmod_articles_categorymod_articles_latestmod_articles_newsmod_articles_popularmod_bannersmod_breadcrumbsmod_custommod_feedmod_findermod_footer

mod_languages mod_loginmod_menumod_random_imagemod_related_itemsmod_searchmod_statsmod_syndicatemod_users_latestmod_weblinksmod_whosonlinemod_wrapper

Page 19: The Joomla Load Module Plugin

Here is my Amazon wish list

And if you really did like this tutorial

Page 20: The Joomla Load Module Plugin

it’s not the endit’s just the beginning ...learn.theartofjoomla.com