Chapter 3: Using Ajax
The basis of how we implement read and update operations when we edit our inline editable content, is that we use Ajax to do this, more specifically, we use Joomla’s com_ajax component.
We shall, now, go into detail on how to use our framework, to implement read and update operations for your component.
Okay, if you remember when we created our folder structure for our package, for inline editing support, we created three files: one for each editable type.
+files_inlinemycck [FILES_INLINE + COMPONENT NAME]
|
------+contexts
|
---+mycck [COMPONENT NAME]
|
-----category.php [TYPE NAME as explained in XML]
|
-----item.php [TYPE NAME as explained in XML]
|
-----blog.php [TYPE NAME as explained in XML]
|
index.html
|
inlinemyck.xml [INLINE + COMPONENT NAME].xml
As you can see, we have three inline editable types in our component:
- Category
- Item
- Blog
In each file, we will create a class that extends the ArkContextsBase. This is the class provided to us by the inline editing framework, that will allow us to do what we discussed above:
- Read the data from the database, for the specified inline type
- Save any updates made by the end user, on inline editing
- render/transform the data back to the user, after saving as it was before any inline editing
The abstract ArkContextsBase contains three methods that will allow our extended class to read, update and render the content for our inline types.
abstract class ArkContextsBase
{
public function get()
public function triggerContentPlugins($rawText)
public function save($data,$type = 'body'){}
}
Let us now see how this works for our simple MyCCK component, in the next section.