I would like to know if someone is aware any guidelines to handle ajax
request in a module.
Something you need to call a PHP script in your module via AJAX. (Example:
a calendar module that contains some data (data are given by ajax request)
Is there some coding rules for that.
Currently my idea was to do something like:
//Load Framework
define( '_JEXEC', 1 );
//Set JPATH_BASE depending on the location of your php script
define('JPATH_BASE', dirname(__FILE__).'/../../../../' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
... then your code.
I was hoping is there is a more secure way, like calling the index.php of
Joomla CMS with some specific param to call a module like we have for
component
something like
index.php?module=my_module&task=gettdata ?
I would recommend that you write a component to handle the Ajax request.
Take a look at xmlrpc changes from 1.5 to 1.6, the changes made are still valid and work great. It will give you quite a bit of flexibility.
As a rule of thumb, I have generally tried to reserve modules for only one purpose, display information. Any task that needs to be handled is handled by a component.
Regards,
Neil
Sent from my iPhone
On Jul 25, 2012, at 9:48 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
> I would like to know if someone is aware any guidelines to handle ajax request in a module.
> Something you need to call a PHP script in your module via AJAX. (Example: a calendar module that contains some data (data are given by ajax request)
> I was hoping is there is a more secure way, like calling the index.php of Joomla CMS with some specific param to call a module like we have for component
> something like
> index.php?module=my_module&task=gettdata ?
> Thomas
> -- > You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Seems to be a big overhead to create a component just for a ajax task of
your module.
I agree with you if you are the developer of the component, all your
modules, plugins should put there ajax code in the component.
But if you want, for example, to create a new K2/SEBLOD field plugin which
will require a value checker in ajax.
Seems to be complicated to explain that you need to install a plugin AND a
component just for a field plugin.
A solution could be to create a "Ajax Request Dispatcher Component" that is
able to call some specific function in the modules or plugins
like
index.php?option=com_ajaxdispatcher&type=module&name=mod_mymodule
then if the component found a mod_mymodule.ajax.php a require is done on
this file.
> I would recommend that you write a component to handle the Ajax request.
> Take a look at xmlrpc changes from 1.5 to 1.6, the changes made are still
> valid and work great. It will give you quite a bit of flexibility.
> As a rule of thumb, I have generally tried to reserve modules for only one
> purpose, display information. Any task that needs to be handled is handled
> by a component.
> Regards,
> Neil
> Sent from my iPhone
> On Jul 25, 2012, at 9:48 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
> Hello,
> I would like to know if someone is aware any guidelines to handle ajax
> request in a module.
> Something you need to call a PHP script in your module via AJAX. (Example:
> a calendar module that contains some data (data are given by ajax request)
> I was hoping is there is a more secure way, like calling the index.php of
> Joomla CMS with some specific param to call a module like we have for
> component
> something like
> index.php?module=my_module&task=gettdata ?
> Thomas
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
So if that is the solution, build it. I think the web services folk
are already thinking that way if you look at their posts on the
mailing list perhaps you can work together with them however if this
is what you feel is required for extensions like plugins and modules
which don't have a component to support them then have a crack at
building it for the greater good.
On Wed, Jul 25, 2012 at 7:40 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
> Hi Neil,
> Seems to be a big overhead to create a component just for a ajax task of
> your module.
> I agree with you if you are the developer of the component, all your
> modules, plugins should put there ajax code in the component.
> But if you want, for example, to create a new K2/SEBLOD field plugin which
> will require a value checker in ajax.
> Seems to be complicated to explain that you need to install a plugin AND a
> component just for a field plugin.
> A solution could be to create a "Ajax Request Dispatcher Component" that is
> able to call some specific function in the modules or plugins
> like
> index.php?option=com_ajaxdispatcher&type=module&name=mod_mymodule
> then if the component found a mod_mymodule.ajax.php a require is done on
> this file.
> 2012/7/25 Swapnil Shah <swapnilsha...@gmail.com>
>> Hey Thomas,
>> I would recommend that you write a component to handle the Ajax request.
>> Take a look at xmlrpc changes from 1.5 to 1.6, the changes made are still
>> valid and work great. It will give you quite a bit of flexibility.
>> As a rule of thumb, I have generally tried to reserve modules for only one
>> purpose, display information. Any task that needs to be handled is handled
>> by a component.
>> Regards,
>> Neil
>> Sent from my iPhone
>> On Jul 25, 2012, at 9:48 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
>> Hello,
>> I would like to know if someone is aware any guidelines to handle ajax
>> request in a module.
>> Something you need to call a PHP script in your module via AJAX. (Example:
>> a calendar module that contains some data (data are given by ajax request)
>> I was hoping is there is a more secure way, like calling the index.php of
>> Joomla CMS with some specific param to call a module like we have for
>> component
>> something like
>> index.php?module=my_module&task=gettdata ?
>> Thomas
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Joomla! General Development" group.
>> To post to this group, send an email to
>> joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Joomla! General Development" group.
>> To post to this group, send an email to
>> joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
A component might seem like a lot of overhead, but it helps me separate things out. And let's be honest it's not that bad. Using a phing script you can create a skeleton quickly, and get to what you want to do. One misconception that I have heard from people is that a component needs a backend and a fronted. You can make a component just for the backend or just for the front end. Number of files are similar to a module and provide you as much of the MVC as you like.
I think for your scenario, you would end up with 2 additional files, but if there is ever a problem. Debugging with a component will be very easy.
I actually wrote a component to handle PDF downloads for a client, it was like 5 files. I can send you a package to take a look when I get home later on today. No fronted view/no backend/no db interaction. It's lean.
Besides making a package that install a component and plugin isn't that bad.
Regards,
Neil
Sent from my iPhone
On Jul 25, 2012, at 10:40 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
> Seems to be a big overhead to create a component just for a ajax task of your module.
> I agree with you if you are the developer of the component, all your modules, plugins should put there ajax code in the component.
> But if you want, for example, to create a new K2/SEBLOD field plugin which will require a value checker in ajax.
> Seems to be complicated to explain that you need to install a plugin AND a component just for a field plugin.
> A solution could be to create a "Ajax Request Dispatcher Component" that is able to call some specific function in the modules or plugins
> like
> index.php?option=com_ajaxdispatcher&type=module&name=mod_mymodule
> then if the component found a mod_mymodule.ajax.php a require is done on this file.
> 2012/7/25 Swapnil Shah <swapnilsha...@gmail.com>
> Hey Thomas,
> I would recommend that you write a component to handle the Ajax request.
> Take a look at xmlrpc changes from 1.5 to 1.6, the changes made are still valid and work great. It will give you quite a bit of flexibility.
> As a rule of thumb, I have generally tried to reserve modules for only one purpose, display information. Any task that needs to be handled is handled by a component.
> Regards,
> Neil
> Sent from my iPhone
> On Jul 25, 2012, at 9:48 AM, Thomas PAPIN <thomas.pa...@gmail.com> wrote:
>> Hello,
>> I would like to know if someone is aware any guidelines to handle ajax request in a module.
>> Something you need to call a PHP script in your module via AJAX. (Example: a calendar module that contains some data (data are given by ajax request)
>> I was hoping is there is a more secure way, like calling the index.php of Joomla CMS with some specific param to call a module like we have for component
>> something like
>> index.php?module=my_module&task=gettdata ?
>> Thomas
>> -- >> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
>> To post to this group, send an email to joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> -- > You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> -- > You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.