Last active
January 1, 2016 17:29
-
-
Save amertkara/8177991 to your computer and use it in GitHub Desktop.
Adding a new category to Joomla (Tested on 3.2) some of the category parameters are dependent on your situation so edit them according to your case (i.e. tag IDs might be different in your database)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define( '_JEXEC', 1 ); | |
define('JPATH_BASE', dirname(dirname(__FILE__))); | |
define( 'DS', DIRECTORY_SEPARATOR ); | |
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); | |
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); | |
$mainframe =& JFactory::getApplication('site'); | |
$mainframe->initialise(); | |
jimport('joomla.application.component.model'); | |
jimport('joomla.application.component.table'); | |
JTable::addIncludePath(JPATH_SITE.'/administrator/components/com_categories/tables','CategoriesTable'); | |
JModelLegacy::addIncludePath(JPATH_SITE.'/administrator/components/com_categories/models','CategoriesModel'); | |
$categoriesModel = JModelLegacy::getInstance('Category','CategoriesModel'); | |
$category = array(); | |
$category['id'] = 0; | |
$category['hits'] = 0; | |
$category['parent_id'] = 10; | |
$category['extension'] = 'com_content'; | |
$category['title'] = 'Title'; | |
$category['alias'] = 'title'; | |
$category['version_note'] = ''; | |
$category['note'] = ''; | |
$category['description'] = 'some description comes here'; | |
$category['published'] = 1; | |
$category['access'] = 1; | |
$category['metadesc'] = ''; | |
$category['metakey'] = ''; | |
$category['created_user_id'] = 0; | |
$category['created_time'] = ''; | |
$category['modified_user_id'] = 0; | |
$category['modified_time'] = ''; | |
$category['language'] = '*'; | |
$category['tags'] = array(2,4); | |
$category['rules'] = array('core.create'=>array('6'=>1,'3'=>1), | |
'core.delete'=>array('6'=>1), | |
'core.edit'=>array('6'=>1,'4'=>1), | |
'core.edit.state'=>array('6'=>1,'5'=>1), | |
'core.edit.own'=>array('6'=>1,'3'=>1)); | |
$category['params'] = array('category_layout'=>'','image'=>''); | |
$category['metadata'] = array('author'=>'','robots'=>''); | |
$categoriesModel->save($category); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment