Documentation

Below you will find documentation on how to use our software. This contains easy-to-use steps by step guides with helpful screenshots on how to configure and get the best results.
 

Categories

chapter 5: Versioning [Step 2: Adding a version method]

In this part, we are going to add a method to our two classes: ARKContextsMyCCKCategory and ARKContextsMyCCKItem we created in the Read and Update section of this tutorial. You will need to do the same for the classes you created specifically for your component.

So, in the ARKContextsMyCCKCategory class for our component, we will add the version method with the code implementation as follows:

public function version($versionId,$type)
{
			
	$historyTable = JTable::getInstance('Contenthistory');
	$historyTable->load($versionId);
	$rowArray = JArrayHelper::fromObject(json_decode($historyTable->version_data));
		
	$item = $this->table;

	$item->bind($rowArray);	
	if($type == 'title')
	{
		return array( 'data'=>$item->title);
	}
	$text = '';
	
	$text = $item->description;

	return array( 'data'=>$text);
}

The version function takes two parameters:

Parameter

Description

Version

Unique ID in History table for the  historic record in the database

Type

Unique type alias used for  Joomla content type

 

The parameters values are supplied by Joomla’s Version Manager when the end user selects a version to revert to from the current content of the editor.

 

As you see in this method, this is standard Joomla stuff. We simply load up a JTable instance of the history table, and then retrieve the specified record using the unique Version ID. Once we attain the database record, we return the historically stored text to the editor to update the current text.

 

Now, zip all your files, basically, zip up the root folder that contains your files and folders you created. So, you will create a zip file like [FILES_INLINE + COMPONENT NAME].zip such as files_inlinemyck.zip in our case.

Okay, now, we will create a Joomla package file, so that we can easily install and manage our inline editing app using Joomla’s Extension Manager.

Joomla package zipped file should contain the following:

public function version($versionId,$type)
{
			
	$historyTable = JTable::getInstance('Contenthistory');
	$historyTable->load($versionId);
	$rowArray = JArrayHelper::fromObject(json_decode($historyTable->version_data));
		
	$item = $this->table;

	$item->bind($rowArray);	
	if($type == 'title')
	{
		return array( 'data'=>$item->title);
	}
	$text = '';
	

	
	$text = $item->introtext;
	if (!empty($item->fulltext))
	{
		$text .= '<hr id="system-readmore" />' . $item->fulltext;
	}


	return array( 'data'=>$text);
	
}

So, that is it for this section.

Well, some of you may be asking: What about the ARKContextsMyCCKBlog class. I have not missed it because it does not need updating as it extends ARKContextsMyCCKItem class, so, it will inherit the version method from that class.

 

Also, some of you may have noticed: I haven’t talked about the textarea extra field. Well, we are going to cover that in the Adding Extra fields section.

 

WebxSolution Ltd is not affiliated with or endorsed by the Joomla! Project or Open Source Matters. The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.

Copyright © 2009 - 2016 WebxSolution Ltd
Powered by JoomlaWired

 

Cron Job Starts