Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2010, 10:07 PM
dfidler dfidler is offline
 
Join Date: May 2008
Location: London, UK
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding Content Types

Hi All,

I am starting work on a plugin that I want to integrate into the vb4 attachment system, which involves adding a new contenttype. I've done some work around this already but have run into a few roadblocks along the way and figured that someone must have tried this already and I'm hoping that they've kept some crib notes.

I know that you need to add a new contenttype (and product), add a php file to /packages/attach/mynewtype.php.

But there seems to be a lot more than that.

Anyways, I'll get there in the end, but if someone does have some crib notes on how they got this done I'd really love to see them. I usually only have 3-5 hours per week to program so you could be saving me weeks of time.

Cheers,
Dave.
Reply With Quote
  #2  
Old 04-01-2010, 09:02 AM
dfidler dfidler is offline
 
Join Date: May 2008
Location: London, UK
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Never mind, I got it. This system is really flexible, but there are a lot of special cases that you have to dig through to get it to work.

I'm taking detailed notes so when I'm confident that i've got it all figured out, I'll post a tutorial on it.

Cheers,
Dave.
Reply With Quote
  #3  
Old 11-11-2010, 09:52 PM
leitel leitel is offline
 
Join Date: Mar 2003
Location: Costa Rica
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I need to import a number of articles. I am trying to hack together a quick function. What follows is my initial attempt. Is there a more elegant approach?

PHP Code:
<?php
define
('VB_PRODUCT''vbcms');
define('VB_ENTRY'1);
define('VB_ROUTER_SEGMENT''content');
define('GET_EDIT_TEMPLATES''picture');
define('CMS_SCRIPT'true);
define('THIS_SCRIPT''vbcms');
define('FRIENDLY_URL_LINK''vbcms');


// here I commented out:
// print_output(vB_Router::getResponse());
require_once('vb/_bootstrap.php');

// here I extended
// class whip_vBCms_Content_Article extends vBCms_Content_Article
require_once('_whip_vBCms_Content_Article.php');

$vBArticle = new whip_vBCms_Content_Article();

$contenttypeid "18";
$sectionid 1;
$parentnodeid 1;
vB::$vbulletin->GPC_exists['parentnode'] = true;
vB::$vbulletin->GPC_exists['sectionid'] = true;
vB::$vbulletin->GPC['sectionid'] = $sectionid;
vB::$vbulletin->GPC_exists['new_contenttype'] = true;
vB::$vbulletin->GPC['parentnode'] = $parentnodeid;
try
{
    
$nodedm = new vBCms_DM_Article();
    
// create content handler
    
$content vBCms_Content::create(vB_Types::instance()->getContentTypePackage($contenttypeid), vBCms_Types::instance()->getContentTypeClass($contenttypeid));


    
// insert default content for the contenttype and get the new contentid

    
$content->setParentNode(vB::$vbulletin->GPC['sectionid']);

    
$contentid $content->createDefaultContent($nodedm);
}
catch (
vB_Exception $e)
{
    throw (new 
vB_Exception_DM('Could not create default content.  Exception thrown with message: \'' htmlspecialchars_uni($e->getMessage()) . '\''));
}

// Create new content node
$nodedm->set('contenttypeid'$contenttypeid);
$nodedm->set('contentid'$contentid);
$nodedm->set('parentnode'$sectionid);
$nodedm->set('title', (vB::$vbulletin->GPC_exists['section_title']?
    
vB::$vbulletin->GPC['section_title'] : vB::$vbulletin->GPC['section_title']) );


//allow child nodes to set the author. This is necessary when we
//promote a post
if (! $nodedm->getSet('userid'))
{
    
$nodedm->set('userid'vB::$vbulletin->userinfo['userid']);
}
$nodedm->setField('title''larry');
if (!(
$nodeid $nodedm->save()))
{
    throw (new 
vB_Exception_DM('Could not create new node for content: ' print_r($nodedm->getErrors())));
}


$vBArticle->createDefaultContent($nodedm);



vB_Cache::instance()->event('section_nav_' vB::$vbulletin->GPC['sectionid']);
vB_Cache::instance()->event('sections_updated');
vB_Cache::instance()->event('articles_updated');
vB_Cache::instance()->cleanNow();



echo 
'';
I know this is a bit of a slop job but just trying to gen something to get the ball rolling.

Thank you
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:30 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05613 seconds
  • Memory Usage 2,212KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete