leitel
11-14-2010, 09:14 PM
I can add new articles but I am struggling with what I thought would be a simple exercise... Update an existing article. What follows are scratch lines of code that I have been experimenting with.
I am looking for code snippet for loading all attributes of a vBCMS Article, alter a field or two, then SAVE the changes.
<?php
define('VB_AREA', 'API');
define('VB_ENTRY', 1);
require('./includes/init.php');
require_once(DIR . '/includes/class_bootstrap_framework.php');
require_once (DIR . "/vb/search/core.php");
require_once (DIR . '/vb/search/indexcontroller/queueprocessor.php');
vB_Bootstrap_Framework::init();
//$c = new vBCMS_DM_Article();
//$content = vBCms_Content::create("vBCms", "Article", "111");
// Get current node info
$node = new vBCms_Item_Content(111);
// Prenotify the node item of info we will require
$info_flags = vBCms_Item_Content::INFO_NODE |
vBCms_Item_Content::INFO_PARENTS |
vBCms_Item_Content::INFO_CONFIG;
$node->requireInfo($info_flags);
if (!$node->isValid()) {
throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found')));
}
$dm = $node->getDM();
$dm->set('title','hello');
$dm->save();
If you have / are doing any direct CRUD with vBCMS articles, I would love to compare notes/code with you.
Thank you :)
I am looking for code snippet for loading all attributes of a vBCMS Article, alter a field or two, then SAVE the changes.
<?php
define('VB_AREA', 'API');
define('VB_ENTRY', 1);
require('./includes/init.php');
require_once(DIR . '/includes/class_bootstrap_framework.php');
require_once (DIR . "/vb/search/core.php");
require_once (DIR . '/vb/search/indexcontroller/queueprocessor.php');
vB_Bootstrap_Framework::init();
//$c = new vBCMS_DM_Article();
//$content = vBCms_Content::create("vBCms", "Article", "111");
// Get current node info
$node = new vBCms_Item_Content(111);
// Prenotify the node item of info we will require
$info_flags = vBCms_Item_Content::INFO_NODE |
vBCms_Item_Content::INFO_PARENTS |
vBCms_Item_Content::INFO_CONFIG;
$node->requireInfo($info_flags);
if (!$node->isValid()) {
throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found')));
}
$dm = $node->getDM();
$dm->set('title','hello');
$dm->save();
If you have / are doing any direct CRUD with vBCMS articles, I would love to compare notes/code with you.
Thank you :)