LemonStand Wiki

Using module access points

Module access points allow you to register special URLs which can be used for different tasks, for example for executing some module specific actions using cron jobs.

Module access points allow you to register special URLs which can be used for different tasks, for example for executing some module specific actions using cron jobs.

In order to register a module access point you need to override the register_access_points() method in the module information class. The module information class has been described in the Developing a simple module article. The register_access_points() method should return an array. Indexes (keys) of the array should match URLs you want to register. Slashes are not allowed in access point URLs. Array values should match the information class method names. Below is an example of the access point registration code.

public function register_access_points()
{
  return array(
    'blog_send_newspaper'=>'send_newspaper'
  );
}

The code registers a single access point with URL 'blog_send_newspaper'. Of your website URL was http://my-site.com/ than the access point URL would be http://my-site.com/blog_send_newspaper.

According to the code example, the module information class should also have the send_newspaper() method definition. It should be a public class method with a single parameter:

public function send_newspaper($params)
{
  /*
   * Some newspaper sending code
   */
}

The method parameter is an array, which contains all parameters presented in the access point URL. For example, if the access point was invoked using the http://my-site.com/blog_send_newspaper/subscribers URL, the $params array would have a single element - 'subscribers'. You can use a many access point parameters as you need.

Access points are not actions and they have no corresponding view documents. You can use the echo() or print() function for outputting some status information.

Next: Handling LemonStand events
Previous: Programming module CMS actions
Return to Developing LemonStand modules

Comments

No comments posted so far.

Add your comment

Loading form...