vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Adding Content Types (https://vborg.vbsupport.ru/showthread.php?t=238874)

dfidler 03-22-2010 10:07 PM

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.

dfidler 04-01-2010 09:02 AM

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.

leitel 11-11-2010 09:52 PM

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 :)


All times are GMT. The time now is 08:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01433 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete