Thank you. It works!!
I noticed however that the new node/article is not found when searching content contained in a newly added article.
Is there a method for forcing an update of the index?
Your post made my day!!!!
--------------- Added [DATE]1289599712[/DATE] at [TIME]1289599712[/TIME] ---------------
I tried this to index the new article:
PHP Code:
vB_Search_Indexcontroller_QueueProcessor::indexNow('vBCms', 'vBCms_Article','index', array_slice(func_get_args(), 3));
Still no joy.
The last parameter is looking for an Associative Array of values. I suppose I can manually populate an array.
--------------- Added [DATE]1289600978[/DATE] at [TIME]1289600978[/TIME] ---------------
Here is the revised code to set publish ON and to index the article immediately. If you adding a batch, it would be better to find the way to index them as a batch.
PHP Code:
<?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();
function create_article($sectionid, $title, $pagetext, $userid, $description = '', $htmltitle = '')
{
global $db;
if (!$htmltitle)
{
$htmltitle = $title;
}
$nodedm = new vBCMS_DM_Article();
$nodedm->info['skip_verify_pagetext'] = true;
$nodedm->set('contenttypeid', vB_Types::instance()->getContentTypeID('vBCms_Article'));
$nodedm->set('parentnode', $sectionid);
$nodedm->set('publicpreview', 1);
$nodedm->set('comments_enabled', 1);
$nodedm->set('pagetext', $pagetext);
$nodedm->set('title', $title);
$nodedm->set('html_title', $htmltitle);
$nodedm->set('description', $description);
$nodedm->set('userid', $userid);
$nodedm->set('publishdate', TIMENOW);
$nodedm->set('url', vB_Friendly_Url::clean_entities($title));
if (!$nodeid = $nodedm->save())
{
return false;
}
else
{
$db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET new = 0, setpublish = 1 WHERE nodeid = $nodeid");
}
$data['nodeid'] = $nodeid;
$data['pagetext'] = $pagetext;
vB_Search_Indexcontroller_QueueProcessor::indexNow('vbcms', 'article','index', $data);
return $nodeid;
}
create_article(1, 'Now is the time for all good martians...', 'Dies ist ein Test', 1, 'foo');
:
Please feel free to share any other code snippets such as adding tags, etc. to an article.
Thanks again for the useful suggestions.