22 Posts
denys
7 years ago
2
Topic

Hi, guys!

How to programmatically add content to Seblod?

For example programmatically add article to Joomla:

<?php

$title = 'Article title';
$intro = 'Introtext here';
$text = 'Fulltext here';
$catid = 1; // Category id

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

$article->title     = trim($title);
$article->alias     = JFilterOutput::stringURLSafe(trim($title));
$article->introtext = $intro;
$article->fulltext  = $text;
$article->catid     = $catid;
$article->created  = JFactory::getDate()->toSQL();
$article->created_by= $user;
$article->state     = $state;
$article->access    = 1;
$article->metadata  = '{"page_title":"","author":"","robots":""}';
$article->language  = '*';

if (!$article->check()) {
    JError::raiseNotice(500, $article->getError());
    return FALSE;
}

if (!$article->store(TRUE)) {
    JError::raiseNotice(500, $article->getError());
    return FALSE;
}

?>
Get a VIP membership
22 Posts
denys
7 years ago
1
Level 1

Wright this code:

$content = new JCckContent( array( 'joomla_article' ) );

$status = $content->create(
                'ju_download',
                array(
                    'title'=>'New CCK DEMO',
                    'catid'=>13,
                    'state'=>1,
                    'language'=>'*',
                    'publish_up'=>JFactory::getDate()->toSql(),
                    'created_by'=> JFactory::getUser()->id
                ),
                array(
                    'jud_description'=>'something',
                    'jud_homepage'=>'{"link":"http:\/\/google.com\/"}',
                    'jud_download_link'=>'{"link":"http:\/\/google.com\/"}',
                    'jud_logo_cover'=>'images/jud/7/222.png',
                    'jud_ext_incl'=>'C,M'

                )
            );
print_r($status);

joomla_article — seblod object

ju_download — my form JU Downlod

jud_* — my fields in form

4229 Posts
Kadministrator
7 years ago
0
Level 2

Get a VIP membership