Skip to content

dart-creations.com

Advertisement
Home arrow Joomla arrow Joomla Tips and Tricks arrow #10 - Load a module within an article
Print E-mail
Saturday, 16 June 2007

#10 - Load a module within an article

Did you know it is possible to actually load a module directly in your content? E.g. We want to load our Featured Articles module in an article rather than in a module position. We can do this using the Load Module Position default Joomla mambot.

 

Joomla 1.5

In Joomla 1.5, there is a default plugin which does this. You can call any module position in a content item with the following code:

{loadposition user4}

Remember, you have to enable the loadmodule plugin from the Plugin Manager.

Joomla 1.0

Edit: See bottom for a new way of doing this, using a 3rd party module though

The Load Module positions mambot allows us to load any mambot position as a mambot. Therefore to load the module in a content article we can use the following workaround.

  • From the Template Positions (Site > Template Manager > User Positions), choose a module position which is not used in your template e.g. user8. If all your positions are used in the template, create a new position.

Create a new template position

  • Assign the module you want to display to the position you have chosen above - Modules > Site Modules. Make sure that Menu Item links is set to All (otherwise the position will not load)

Setup the module with all necessary parameters

  • In your content item enter the following: { mosloadposition user8 } (be sure to remove extra spaces before mosloadposition and after user8, spaces were added intentionally in this example). This will be replaced by the content of the module(s) assigned to that position.

Insert the mambot text into your content

Below is an example of usage of this module. We are loading the Featured Articles Module in the content of this article:

Another good example of usage of this module is this. You want to create an advert (or affiliate link), but instead of copying and pasting the code, you want to be able to replicate this advert at will in your content items. Therefore you use the mod_html module to create the advert you need. Now, each time you want to display this advert, you just insert the { mosloadposition xxxx } (be sure to remove extra spaces before mosloadpostion and after xxxx, spaces were added intentionally in this example)  in the content. The good thing about this is that if you want to change the advert, you only need to change this in the module rather than in every content item.

Edit: There is a cool module which allows you to avoid all the hassle above. Amongst various functions it allows you to use code as follows to do the above in a much simpler manner:

{mosmodule modulename} and the module is immediately loaded.  

Comments
Search RSS
Ryan  - Load module positions mambot   |71.8.211.xxx |2007-07-14 22:37:04
Ive used this technique to load in my news content using the mod_latestnews
module. When I do the news module loads perfectly. But
for some reason, the content item that I put the call in
also shows up as a news item. I dont want this to be a news item. How would i
overcome this?
DART Creations  - Load module positions mambot   |85.232.196.xxx |2007-07-15 05:26:04
The latest news items by default shows: "a list of the most recently
published Items that are still current". Therefore since the last thing you
do when you do the above technique is to save the current content item, this is
causing the current content item to be the most recently published item, and
thus included in the news.

To overcome it, guess you would need to publish more
changes, such that the current item bubbles down the Latest News module. The
best option would be to start with the item that contains the Latest news, and
then enter the other items after it such that they are more recent.
Tumbleweed  - Load module positions mambot -   |75.92.242.xxx |2008-02-06 14:59:10
This function has changed in Joomla 1.5 and is now a default plugin with your
Joomla install. You can call any module position in a content item with the
following code:

{loadposition user4}

Remember, you have to enable the
loadmodule plugin from the Plugin Manager.

That is all,
Tumbleweed
koamang  - Bali Web Design   |125.162.135.xxx |2008-02-07 15:42:38
very usefull
great tutorial

thanks anyway
http://www.balipublisher.com
Arthur  - dcode communications   |72.252.152.xxx |2008-06-13 19:09:40
thank you. i could not remember this for the life of me
killer  - joomla   |89.38.249.xxx |2008-08-27 10:26:09
great tutorial
eleni  - loadmodule   |213.5.178.xxx |2008-10-07 13:10:42
loadmodule is not working in internet explorer...
the plug in is enabled, but is
still not working....
can anyone help me??
Adan  - Is this what I am looking for ?   |207.45.249.xxx |2009-01-15 14:12:10
What I would like to do is the following:

I created a menu using menu
manager. It is easy to let an item of this menu displays an article in the
frontpage when clicked on. However, I did not find how to let it display in the
frontpage the output of a module. Is what you are suggesting can do that ?
You
said "We want to load our Featured Articles module in an article rather than
in a module position", seems that this is exactly what I would like to do.
However, I don't see where should I put {loadposition user4} ? In the definition
of the menu ? In the definition of an article ? Where ?

I am using Joomla!
1.5.9

Any help?
DART  - LoadPosition   |Administrator |2009-01-15 14:48:14
Hi Adan,

1. Enable the load position plugin
2. Ensure you have setup the
position you want to load in the article
3. insert {loadposition user4} in the
article where you want the position to load. Remember if the position you want
to load is top, you'd need to insert {loadposition top}
adan  - Worked fine ... but   |207.45.249.xxx |2009-01-16 16:44:27
Thanks for your answer. I tried this method using the banner module and it works
fine. However, when trying it with a virtuemart module
(mod_virtuemart_latestprod) it did not work. My page stays empty.

However
this module works fine when I add it to the left of page.

Any idea?
DART   |Administrator |2009-01-16 18:08:04
Maybe its best to ask at the VirtueMart forums ...
FidelGonzales  - But How Do You Insert Into A Joomla 1.5 Module     |71.119.75.xxx |2009-01-28 23:28:44
How Do You Insert Modules Into A Joomla 1.5 Module, as loading the standard

{loadposition user4} does not work. Thanks.
DART  - Joomla 1.5 Module   |Administrator |2009-01-29 07:03:18
No, the plugin does not work with Joomla 1.5 within modules. This is a
limitation of Joomla 1.5 as opposed to Joomla 1.0.
dick  - load position issue     |220.233.7.xxx |2009-02-21 06:33:00
hi,

Joolma 1.5
location : in a test directory .../newsite/
Issue: the
loadposition works in a artical only but when the front page is endabled,
truning off the enaled will show the following - {loadposition xxx}. The
loadposition is enabled.... Please help

dick
rajendra   |122.169.52.xxx |2009-03-10 11:04:32
hello i have used

{loadmoduleposition footer}

as u indicate in my content
area

but it gives error

Parse error: syntax error, unexpected T_STRING in
D:\wamp\www\Eticket\components\
;com_eventlist\views\categoriesdetailed 2;tmpl\default_table.php
on line 140

and i have Joomla 1.5.9
rajendra  - re:   |122.169.52.xxx |2009-03-10 11:05:31
rajendra wrote:
hello i have used

{loadposition footer}

as u indicate in my content area


but it gives error

Parse error: syntax error, unexpected T_STRING
in D:\wamp\www\Eticket\components\ ;com_eventlist&#
92;views\categoriesdetailed  2;tmpl\default_table.php on line
140

and i have Joomla 1.5.9
Mark Stratton  - loadposition for text area     |74.209.37.xxx |2009-05-17 23:28:23
Hey ya'll,

I have been tring to create a text area to hold some html
code.

This may work for the text area...
INSERT HTML MESSAGE HERE

I have
tried...
,
{loadposition user4}

Any ideas?
DART   |Administrator |2009-05-18 06:19:27
I think Joomla may not be very textarea friendly...
Mike  - Loadposition not working in Blog layout     |68.104.143.xxx |2009-06-07 22:51:26
I have loadposition working for a GoogleAd and Yieldbuild ad. When I use the
loadposition command and am viewing the page as a single article, both show up.
But when I change the view to Blog Style, only the Google Ad shows. Any ideas?
anga  - I'm Lost   |67.34.41.xxx |2009-06-10 17:33:55
I have Joomla 1.5 installed, but Legacy is enabled. Does that affect this? I'm
reading the tutorial and all the reader comments, but still am lost on how to
insert the paypal button into an article.
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Saturday, 27 December 2008 )
 

Sponsors

Login Form






Lost Password?
No account yet? Register

Buy us a beer!

If we've helped you, consider buying a beer €3. It will inspire us to keep on giving! Cheers!


Generated in 0.28367 Seconds