NOTE:
- the following was test but it may be incomplete if you have a fix / suggestion for the following then post in our forums
// Create a log file
$user = JFactory::getUser();
$log_filename = 'my_log_'.($user->id).'.php';
jimport('joomla.log.log');
JLog::addLogger(array('text_file' => $log_filename));
// **************************************
// Include the needed classes and helpers
// **************************************
if (!defined('DS')) define('DS',DIRECTORY_SEPARATOR);
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.helper.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.categories.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.fields.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.acl.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'permission.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php');
// Add component's table directory to the include path
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
// ***
// *** Load language files
// ***
// (BACKEND) Load english language file for 'com_flexicontent' component then override with current language file
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true);
// ***
// *** Create the item model object
// ***
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'type.php');
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'field.php');
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'tag.php');
$model = new FlexicontentModelType(); // new FlexicontentModelField(); // new FlexicontentModelTag();
// Create the new item data
$data = array();
// 444 is the id of the item that you want to load, or set it to zero for new item
$record_ID = 444;
if ($record_ID)
{
// EITHER Load existing item into the ITEM model
$record = $model->getItem($record_ID);
// You can use $record to get existing values
if (!$record) die('record ' . $record_ID . ' not found');
// Indicate which item to update
$data['id'] = $record_ID;
}
else
{
// OR indicate a new record will be created
$data['id'] = 0;
}
// See DB table (for more properties)
$data['title'] = ...;
$data['alias'] = ...; // or $data['name'] = ...;
// Store the new / existing record and log the result in file and on screen
if ( !$model->store($data) )
{
$msg = 'Failed to store item: '. $model->getError();
JLog::add($msg);
echo $msg."<br/>";
}
Also if the above IS NOT inside a Joomla extension, then you will need to load the Joomla Framework before calling the above code, by using:
// Get Joomla! framework
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$app = JFactory::getApplication('site');
$app->initialise();
// Define component paths IF FLEXIcontent v3.1.0 or older
// You do not need them for v3.1.1 or later !!
define( 'JPATH_COMPONENT_SITE', JPATH_SITE.DS.'components'.DS.'com_flexicontent' );
define( 'JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent' );
In the above we assume that you custom script is located in your site root, if it is located in a subfolder: custom/myscripts/ then use:
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));