How to invoke a module from a component's view?

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Locked
EdRotberg
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Wed Jan 30, 2008 7:50 pm
Location: Nevada City, CA, USA

How to invoke a module from a component's view?

Post by EdRotberg » Tue Jul 08, 2008 9:46 pm

Hi,

I have a custom component where I'd like to invoke a module that's already installed into a view in my component. I know that I can invoke this module from an ordinary article by using the {loadposition 'position'} syntax where 'position' is a custom position assigned to that module. I tried doing this in the html of my view, but as I had guessed, it didn't work and just displayed {loadposition 'position'} directly on the view''s output.

Is there a simple way to do this?

Thanks in advance,

= Ed =
A waist is a terrible thing to mind!

User avatar
jenscski
Joomla! Ace
Joomla! Ace
Posts: 1468
Joined: Thu Aug 18, 2005 6:58 am
Location: Tønsberg, Norway

Re: How to invoke a module from a component's view?

Post by jenscski » Wed Jul 09, 2008 5:07 am

The easiest way of doing this is:

Code: Select all

jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('modulename');
echo JModuleHelper::renderModule($module);
But if you want more control of the output, then take a look at the code that parses the {loadmodule ...} syntax.

This is located in the content plugin loadmodule in the file plugins\content\loadmodule.php
Jens-Christian Skibakk
MMS Blog - http://mms.pipp.no/
Joomla! i Norge / Joomla! in Norway - http://www.joomlainorge.no/

EdRotberg
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Wed Jan 30, 2008 7:50 pm
Location: Nevada City, CA, USA

Re: How to invoke a module from a component's view?

Post by EdRotberg » Wed Jul 09, 2008 5:33 am

Thanks. That worked like a charm. I only need to use this module from my component and I can control the output of the module from the module manager as much as I need. Thanks again!

= Ed =
A waist is a terrible thing to mind!

User avatar
subfighter
Joomla! Intern
Joomla! Intern
Posts: 60
Joined: Wed Feb 07, 2007 7:26 pm
Location: Oceanside
Contact:

Re: How to invoke a module from a component's view?

Post by subfighter » Sun Jul 20, 2008 9:04 pm

i tried using this to display a module that i want displayed inside this component template i am creating.. but it does not show anything???

does this work for joomla 1.5x series ???
Rick Estrada
http://www.jomtube.com - Video Gallery Component
http://www.subfighter.tv - Mixed Martial Arts Social Network

EdRotberg
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Wed Jan 30, 2008 7:50 pm
Location: Nevada City, CA, USA

Re: How to invoke a module from a component's view?

Post by EdRotberg » Tue Jul 22, 2008 2:48 pm

subfighter wrote:i tried using this to display a module that i want displayed inside this component template i am creating.. but it does not show anything???

does this work for joomla 1.5x series ???
Yes, I'm using 1.5 and it worked like a charm for me.

= Ed =
A waist is a terrible thing to mind!

waisign
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Tue May 02, 2006 3:18 am

Re: How to invoke a module from a component's view?

Post by waisign » Wed Aug 20, 2008 3:57 am

after lurking in the forum on so many threads,

you jenscski my friend, are a genuis! ^^

Works like magic. Many thanks :)


Locked

Return to “Joomla! Coding 101”