Skip Navigation

Text Only/ Printer-Friendly

Implementing Reason Inline Editing

Reason modules that support inline editing allow authorized users to make changes to content without using the Reason administrative interface. This guide describes the components of the inline editing implementation and presents best practices for implementing inline editing in custom modules.

Overview

Reason 4 Beta 8 includes inline editing support for page content and text blurbs. While any module can implement inline editing, only one module should be active for editing at a time. Modules that implement inline editing need to provide a toggle to turn editing on and off, and also need to use the Reason inline editing class to determine appropriate activation / deactivation parameters to avoid conflicts with other modules.

Inline Editing Class

reason_package/reason_4.0/lib/core/classes/inline_editing.php

The inline editing class manages all aspects of inline editing. Any module that implements inline editing needs to register with the a shared instance of this class that is obtained through the function &get_reason_inline_editing($page_id).

Modules should use the following class methods:

register_module(&$module, $available)

Any module that implements inline editing should pass a reference to itself, and a boolean value that indicates whether the current user has the appropriate privileges to inline edit. Typically, this would be users who have administrative access to a site, but a given module can user whatever criteria it wants to decide whether inline editing is available.

available_for_module(&$module)

This method should be used to determine whether or not inline editing is available. If it is available, this means that inline editing is available in Reason and that the current user has inline editing privileges for the module.

active_for_module(&$module)

This method should be used to determine whether or not inline editing is active. If it is active, this means that the proper activation parameters for the module are present in the $_REQUEST. Since the activation value for each module is unique, and the $_REQUEST key is shared, only one module can be active at a time when inline editing is properly implemented.

get_activation_params(&$module)

Returns an array with the appropriate key / value pair to activate inline editing for a particular module. The return value of get_activation_params should be used along with carl_make_link to create a URL that can be used to make an activation link.

get_deactivation_params(&$module)

Returns an array with the appropriate key / value pair to deactivate inline editing for a particular module. While the use of this is likely implemenation specific, a common case would be to assemble a URL for redirection in the where_to phase of a save and finish action in an editing interface.

Implementation Example - the Content Module

We'll look at each relevant method of the content module (reason_package/reason_4.0/lib/core/minisite_templates/modules/content.php) to see how it implements inline editing.