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.
-
1Basically 99% of modules "read in some parameters" and "do a database search and display the results." You will have to be more specific about what you mean. If you are saying you want to be able to enter queries from a UI you would just do that as part of a form, but I'd say that would be pretty dangerous. – Elin Jul 27 '14 at 20:38
2 Answers
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

- 9,335
- 2
- 34
- 38
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.

- 1,873
- 1
- 12
- 14