$category =& JTable::getInstance('Category');
$category->title = [title];
$category->parent_id = [parent id];
$category->level = [level];
$category->extension = 'com_content';
$category->published = 1;
$category->params = json_encode(array('category_layout' => '', 'image' => ''));
$category->language = '*';
$category->metadata = json_encode(array('author' => '', 'robots' => ''));
$category->access = 1;
$category->setLocation([parent id], 'last-child');
if (!$category->check()) {
echo $category->getError();
}
if (!$category->store()) {
echo $category->getError() . ' ( row: ' . $i . ')';
}
if (!$category->rebuildPath($category->id)) {
echo $category->getError();
}
if (!$category->rebuild($category->id, $category->lft, $category->level, $category->path)) {
echo $category->getError()
}
$category->title = [title];
$category->parent_id = [parent id];
$category->level = [level];
$category->extension = 'com_content';
$category->published = 1;
$category->params = json_encode(array('category_layout' => '', 'image' => ''));
$category->language = '*';
$category->metadata = json_encode(array('author' => '', 'robots' => ''));
$category->access = 1;
$category->setLocation([parent id], 'last-child');
if (!$category->check()) {
echo $category->getError();
}
if (!$category->store()) {
echo $category->getError() . ' ( row: ' . $i . ')';
}
if (!$category->rebuildPath($category->id)) {
echo $category->getError();
}
if (!$category->rebuild($category->id, $category->lft, $category->level, $category->path)) {
echo $category->getError()
}
No comments:
Post a Comment