Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Joomla 2.5 module parameters for a module not assigned to the current page
    text
    copied!<p>I want to get the parameters of a module which is not assigned to the the current page. The helper class JModuleHelper has a getModule method but as defined here: <a href="http://docs.joomla.org/JModuleHelper/getModule" rel="nofollow">http://docs.joomla.org/JModuleHelper/getModule</a>, the module must be assigned to the current menu item or all menu items.</p> <p>Obviously I can just go into the database and pull out the parameters myself, but I wanted to do it in a neater Joomla way.</p> <p>What I'm trying to do is write a library, but the library requires some parametrization and its own database tables (two things that libraries cannot do), so I'm trying to use a module to fill the gaps. I need to access the module parameters from the library code (which could be called from any page on the site).</p> <p>Thanks for any help</p> <hr> <p>The solution I've gone with is to add the following code to my library:</p> <pre><code>$db = JFactory::getDbo(); $query = $db-&gt;getQuery(true); $query-&gt;select('m.params') -&gt;from('#__modules AS m') -&gt;where('m.module=' . $db-&gt;quote('mod_my_module_name')); $db-&gt;setQuery($query); $module = $db-&gt;loadObject(); $module_params = new JRegistry(); $module_params-&gt;loadString($module-&gt;params); </code></pre> <p>I've not added this as an answer to this question because I think there should be a better solution which doesn't directly query the core database. However I think that the above is the best solution for now.</p> <hr> <p>Update</p> <p>Based on an answer to this question on the Joomla! developer group I've implemented a library/plugin solution. Plugins can have parameters which can be pulled from anywhere using the code:</p> <pre><code>$plugin = JPluginHelper::getPlugin('plugin_type', 'plugin_name'); $parameteres = new JRegistry($plugin-&gt;params); $param =$parameteres-&gt;get('parameter'); </code></pre> <p>The advantage of plugins over modules is that there is no requirement to assign the plugin to all item id's as their is with modules.</p> <p>The more I've looked into it, the more confident I am that no elegant solution to my original question, of getting the parameters of modules not assigned to the current item id. So if you have found this question because you want to do something similar then I would recommend my solution above or cppl's solution below. Both will work and there probably isn't much to choose between them</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload