Last active
June 8, 2019 09:27
-
-
Save volandku/5f4b07e8765cd613a23dbb0ebde90fe3 to your computer and use it in GitHub Desktop.
joomla cli create category example
This file contains hidden or 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 | |
/** | |
* @package ${NAMESPACE} | |
* @subpackage | |
* | |
* @copyright A copyright | |
* @license A "Slug" license name e.g. GPL2 | |
*/ | |
const _JEXEC = 1; | |
error_reporting(E_ALL | E_NOTICE); | |
ini_set('display_errors', 1); | |
// Load system defines | |
//if (file_exists(dirname(__DIR__) . '/defines.php')) | |
//{ | |
// require_once dirname(__DIR__) . '/defines.php'; | |
//} | |
if (!defined('_JDEFINES')) | |
{ | |
// define('JPATH_BASE', dirname(__DIR__).'/../../../..'); | |
define('JPATH_BASE', dirname(__FILE__)); // если не в корне - добавить выше сколько надо | |
require_once JPATH_BASE . '/includes/defines.php'; | |
} | |
require_once JPATH_LIBRARIES . '/import.legacy.php'; | |
require_once JPATH_LIBRARIES . '/cms.php'; | |
// Load the configuration | |
require_once JPATH_CONFIGURATION . '/configuration.php'; | |
class wsCreateCategory extends JApplicationCli | |
{ | |
public $helper = null; | |
public $plugins = null; | |
public $starttime = null; | |
public function doExecute() | |
{ | |
$app = JFactory::getApplication('administrator'); //Вот только плевать на переданные параметры!! | |
$app->loadSession(); | |
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php'); | |
$table = array(); | |
$table['title'] = 'Новая категория 2'; | |
$table['parent_id'] = 8; | |
$table['extension'] = 'com_content'; | |
$table['language'] = '*'; | |
$table['published'] = 1; | |
$table['created_user_id']=$table['modified_user_id']=969; // айди юзера | |
$table['metadata']='{"author":"","robots":""}'; | |
$table['params'] = '{"category_layout":"","image":"","image_alt":""}'; | |
// Create new category and get catid back | |
$data['catid'] = CategoriesHelper::createCategory($table); // вернет по идее айди новой | |
} | |
} | |
JApplicationCli::getInstance('wsCreateCategory')->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment