Forums

Create Joomla article with CF5.

cervinim 21 Jun, 2018
Hi everybody!πŸ™‚
I'm Sorry for my bad English speaking. πŸ˜‰
I've create a form that post an Article in a category: this work properly but a frontend user can't edit this article. face-meh-blank
I've checked the permission on the container category and it's correct, the group of my user have full access to this category.
I've found in an other forum that this depend by the fact that chronoforms not write the record of the new article in #_assets table. 😫
If I edit and save the article in the backend, all works properly and the frontend user now can edit! (the record of the new article in #_assets table was created!) 🧐

There's a workaround for this?

Thanks everyone! πŸ˜€
cervinim 25 Jun, 2018
Answer
Hi everybody,
finally I've found a workaround: I use Joomla API instead Joomla Article Function in CF5 and it works fine!

Here is the code:
<?php
if (version_compare(JVERSION, '3.0', 'lt')) {
JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table');
}

$article = JTable::getInstance('content');

$article->title = $form->data['my_title'];
$article->alias = JFilterOutput::stringURLSafe($form->data['my_title']);
$article->introtext = $form->data['my_introtext'];
$article->fulltext = $form->data['my_fulltext'];
$article->catid = my_cat_ID;
$article->created = JFactory::getDate()->toSQL();;
$article->created_by_alias = JFactory::getUser()->get('name');;
$article->state = 0; 'disabled
$article->access = 1;
$article->metadata = '{"page_title":"","author":"","robots":""}';
$article->language = '*';

// Check to make sure our data is valid, raise notice if it's not.
if (!$article->check()) {
JError::raiseNotice(500, $article->getError());
return FALSE;
}

// Now store the article, raise notice if it doesn't get stored.
if (!$article->store(TRUE)) {
JError::raiseNotice(500, $article->getError());
return FALSE;
}
?>
This topic is locked and no more replies can be posted.