Re: [jgen] Get module paremeters from elsewhere!!!

1,557 views
Skip to first unread message

fornandakishore

unread,
Aug 3, 2012, 12:23:43 AM8/3/12
to joomla-de...@googlegroups.com
Hello Harmer,

Try to use this code ...

jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_login', 'YourModuleTitle');
//echo JModuleHelper::renderModule($module);

I hope this code will help you to give the specified module parameter in any component, module and plugin.
 
Thanks & Regards

Nanda Kishore. M

Senior PHP Developer

http://php-desk.blogspot.com

Mobile: + 91 98499 71144 




On Fri, Aug 3, 2012 at 12:54 AM, KHarmer <kristia...@gmail.com> wrote:
Hi all,

I have a custom module with custom paramaters which I'd like to be able to get from either a plugin (non-related) or from the modules helper file.

The reason being is that these paramaters can/will be used by other extensions.

I've googled and cannot find anything that works; I can only load the modules parameters from the modules own tmpl file or the modules own definition file!

Any ideas would be gratefully received.

Best regards,
K...

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/wKBkfhpXT9cJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


allon moritz

unread,
Aug 3, 2012, 12:56:51 AM8/3/12
to joomla-de...@googlegroups.com
Because joomla doesn't provide a way to get the params by module id (mostly you don't have the module title!!) I get it from the table directly
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('m.*');
$query->from('#__modules AS m');
$query->where('id = '.JRequest::getInt('moduleid'));
$db->setQuery($query);
$module = $db->loadObject();
$params = new JRegistry($module->params);

I also don't like to get it form the database rather than via API, but I was searching up and down for a function to get the params by module id via API.

piotr_cz

unread,
Aug 3, 2012, 4:18:21 AM8/3/12
to Joomla! General Development
It seems that module parameters are being loaded as string in
JModuleHelper::getModule().

You could convert these to a JRegistry using:

// Get First module
$module = JModuleHelper::getModule('mod_login')

// Get module parameters
$params = new JRegistry;
$params->loadString($module->params);


But, as Allon Moritz mentioned this doesn't filter module by id and
'title' is up to user.

If you are inside the module itself, you may use $params variable.

I guess it was an unlikely scenario to prepare loading module
paramaters for other reasons that in template positions or inside a
module.


On Aug 3, 6:56 am, allon moritz <allon.mor...@gmail.com> wrote:
> Because joomla doesn't provide a way to get the params by module id (mostly
> you don't have the module title!!) I get it from the table directly
> $db = JFactory::getDbo();
> $query = $db->getQuery(true);
> $query->select('m.*');
> $query->from('#__modules AS m');
> $query->where('id = '.JRequest::getInt('moduleid'));
> $db->setQuery($query);
> $module = $db->loadObject();
> $params = new JRegistry($module->params);
>
> I also don't like to get it form the database rather than via API, but I
> was searching up and down for a function to get the params by module id via
> API.
>
> On Fri, Aug 3, 2012 at 6:23 AM, fornandakishore
> <fornandakish...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hello Harmer,
>
> > Try to use this code ...
>
> > jimport('joomla.application.module.helper');
> > $module = JModuleHelper::getModule('mod_login', 'YourModuleTitle');
> > //echo JModuleHelper::renderModule($module);
>
> > I hope this code will help you to give the specified module parameter in
> > any component, module and plugin.
>
> > Thanks & Regards
>
> > Nanda Kishore. M
> > Senior PHP Developer
>
> >http://php-desk.blogspot.com
>
> > Mobile: + 91 98499 71144
>

Ove

unread,
Aug 3, 2012, 10:49:56 AM8/3/12
to joomla-de...@googlegroups.com, piotr_cz
IMHO it's not possible to use module parameters from another extension.
Wich module? You can have a couple of them if the user clicks on the
Duplicate button. You do not have any unique identifier, On a private
site you can hardcode it but not for a general solution. I guess you'll
need a small backend component to set the needed general parameters.

Ove

Carlos M. Cámara

unread,
Aug 3, 2012, 12:58:54 AM8/3/12
to joomla-de...@googlegroups.com
Using module params from one module would work for a specific design, as to get the specific module instance you have to set type of module and title, but if the user has 2 modules, or if the user changes the module title, this will not work.

Obviously solution provided by Allon Moritz will work too, as far as you know the specific module id.

All best!!

I think it would be better to set these parameters in a component. This way you guarantee that not matter what user makes with the module, your parameters will remain the same.

On Fri, Aug 3, 2012 at 6:23 AM, fornandakishore <fornand...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages