简体   繁体   中英

How to pass variables to Joomla modules?

I am trying to make a Joomla website, where entries from the SQL database would be shown depending of different queries. I would like to write a universal module, which could read in some parameters (as a normal function would do), then do a database search and display the results. I cannot find a way to do this. I can only hardcode some rules inside the module but there is no access to the module from the Joomla administrator panel. Thanks in advance.

I'm guessing here that you're tyring to build something similar to an AJAX search module , given that there are lots of these on the Joomla Extensions Directory , I would recommend looking at several of these modules to see how they did it.

Depending on your specific version of Joomla and the way you implement it you may be able to use the AJAX Interface in 3.2+ versions of Joomla

Are the URL parameters you need available on initial page load? If so, you can simply use the JApplication input object to retrieve cleansed GET/POST parameters.

$jinput = JFactory::getApplication()->input;
$myVar = $jinput->get('myVar', 'default my var value if not avail');

You could then capture the needed parameters to build out your DB query.

If the parameters are not available and the data needs to be acquired through an AJAX call, you could use cppl's solution or roll your own using this tutorial.

http://docs.joomla.org/JSON_Responses_with_JResponseJson

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM