Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Best Pratice - Howto execute a PHP script in your module code via an AJAX
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas PAPIN  
View profile  
 More options Jul 25 2012, 9:48 am
From: Thomas PAPIN <thomas.pa...@gmail.com>
Date: Wed, 25 Jul 2012 15:48:02 +0200
Local: Wed, Jul 25 2012 9:48 am
Subject: Best Pratice - Howto execute a PHP script in your module code via an AJAX

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)

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 ?

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Swapnil Shah  
View profile  
 More options Jul 25 2012, 9:56 am
From: Swapnil Shah <swapnilsha...@gmail.com>
Date: Wed, 25 Jul 2012 09:56:15 -0400
Local: Wed, Jul 25 2012 9:56 am
Subject: Re: [jgen] Best Pratice - Howto execute a PHP script in your module code via an AJAX

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas PAPIN  
View profile   Translate to Translated (View Original)
 More options Jul 25 2012, 10:40 am
From: Thomas PAPIN <thomas.pa...@gmail.com>
Date: Wed, 25 Jul 2012 16:40:38 +0200
Local: Wed, Jul 25 2012 10:40 am
Subject: Re: [jgen] Best Pratice - Howto execute a PHP script in your module code via an AJAX

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>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile   Translate to Translated (View Original)
 More options Jul 25 2012, 12:28 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Wed, 25 Jul 2012 09:28:20 -0700
Local: Wed, Jul 25 2012 12:28 pm
Subject: Re: [jgen] Best Pratice - Howto execute a PHP script in your module code via an AJAX
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.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Swapnil Shah  
View profile  
 More options Jul 25 2012, 1:04 pm
From: Swapnil Shah <swapnilsha...@gmail.com>
Date: Wed, 25 Jul 2012 13:04:41 -0400
Local: Wed, Jul 25 2012 1:04 pm
Subject: Re: [jgen] Best Pratice - Howto execute a PHP script in your module code via an AJAX

Hey Thomas,

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »