Difference between revisions of "Adding custom web service functions"

From Joomdle
Jump to: navigation, search
m
 
Line 25: Line 25:
  
  
Once the new functions is added to Joomdle service, you can use this code to call it:
+
Once the new function is added to Joomdle service, you can use this code to call it:
  
 
<syntaxhighlight>
 
<syntaxhighlight>

Latest revision as of 18:13, 4 February 2019

Sometimes it can be handy to create some custom Moodle web service functions that you could use alongside Joomdle stock ones.

For example, you may want to generate some custom report in Joomla that uses Moodle data, some of which it is not offered by Joomdle.


In those cases, you can create a new Moodle plugin of type Local:

https://docs.moodle.org/dev/Local_plugins


You can then have your functions there, and add them to Joomdle web service so you can call them as you would call any other Joomdle functions.

The only thing you have to remember is to have your functions names prefixed with 'joomdle_' so you can call them with Joomdle's call method in Joomla.


Here you can find an example plugin to help you get started:

https://www.joomdle.com/download/category/35-development?download=112:moodle-web-services-demo

You need to install it in Moodle, and then go to Moodle admin->Plugins->Web services->External Services.

Look for Joomdle external service and click Functions. You will see the list of Joomdle functions. Go to the bottom of the page and click Add functions.

Search for "joomdle" and the new testjoomdlewsdemo should appear. Select it and click "Add functions".


Once the new function is added to Joomdle service, you can use this code to call it:

    $return = JoomdleHelperContent::call_method ('testjoomdlewsdemo', "TEST STRING");
    print_R ($return);