The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to create a article via API / auto-create of articles
Hey there,
is there any reference or tutorial on how to create articles with the API? Or even better, is there something like a mod or a function to automatically create articles out of threads which are posted in a specific forum? greeting |
#2
|
|||
|
|||
hi, i would also like to know if there is anyway this can be done,
I want to have an rss feed post straight to an article (primary content) I would really appreciate it if someone could help! |
#3
|
|||
|
|||
*bump* any news on this? do you think the vb-team will reply with a solution if I ask them via a support ticket?
|
#4
|
|||
|
|||
I contacted the official support and got this answer, in case someone also wants to know how to do it:
Quote:
|
#5
|
|||
|
|||
Has anyone come up with an interim hack/mod/solution? Although the API will be very useful, I need something to import a batch of articles NOW. I'll accept any scraps / code snippets. Thank you
|
#6
|
|||
|
|||
Well I got a direct response from a vB developer with some information for creating articles via own code. Also i got a code example by an user of vbulletin-germany.org.
Code Example (provided by Andreas http://www.vbulletin-germany.org/sho...96&postcount=4, modified by me): Code:
<?php define('VB_AREA', 'API'); require('./includes/init.php'); require_once(DIR . '/includes/class_bootstrap_framework.php'); vB_Bootstrap_Framework::init(); function create_article($sectionid, $title, $pagetext, $userid, $categoryid = '', $datestamp = '', $description = '', $htmltitle = '') { global $db; if (empty($htmltitle)) $htmltitle = $title; if (empty($categoryid)) $categoryid = 41; $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('url', vB_Friendly_Url::clean_entities($title)); $nodeid = $nodedm->save(); if (empty($nodeid)) { return false; } else { $db->query_write("INSERT INTO ". TABLE_PREFIX . "cms_nodecategory (nodeid, categoryid) values (" . $nodeid . ", $categoryid) "); $db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET new = 0 WHERE nodeid = $nodeid"); if(empty($datestamp) OR $datestamp < 946681200) // if datestamp is empty or before 01.01.2000 { $datestamp = TIMENOW - vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo, false); // use current datestamp } $db->query_write("UPDATE " . TABLE_PREFIX . "cms_node set setpublish = 1, publishdate = $datestamp WHERE nodeid = $nodeid"); } return $nodeid; } echo create_article(113, 'Headline', 'article text', 1); ?> Quote:
|
#7
|
|||
|
|||
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:
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:
Please feel free to share any other code snippets such as adding tags, etc. to an article. Thanks again for the useful suggestions. |
#8
|
|||
|
|||
Quote:
to add tags, just add the following line into the method: Code:
$nodedm->set('keywords', $keywords); Code:
function create_article($sectionid, $title, $pagetext, $userid, $description = '', $htmltitle = '', $keywords = '') |
#9
|
|||
|
|||
I did a test to see if item is added to the index after it is added. I removed my code:
PHP Code:
I added the param for keywords and that works great. However, I don't see a method for associating tags vs keywords. I am referring to the tags that form the basis for tag cloud. --------------- Added [DATE]1289654370[/DATE] at [TIME]1289654370[/TIME] --------------- I was mistaken. My code to immediately update index with new article is wrong. It isn't working. I also tried Verify and Repair Node Table. |
#10
|
|||
|
|||
Sorry, thought the keywords were interpreted as tags.
To add tags to the article look in the following class: Quote:
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|