vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   VBCMS Plugin Woes (https://vborg.vbsupport.ru/showthread.php?t=267092)

Carpesimia 07-19-2011 07:22 PM

VBCMS Plugin Woes
 
Hi Team,

I'm trying to write a plugin that will affect each of the articles on the VBCMS home. I want to evaluate something for each article, and if i find what I am looking for, I want to show some text or an image on that specific preview.

So, I've run into some issues:

1) I cannot even get anything from a plugin to show in the "vbcms_content_article_preview" template. None of the vbcms_xxxx hooks worked, so i even tried global_start (which im using for similar logic in navbar template), which still doesnt work. Here's my test code:

Hook: global_start

Code:

$testme = "abc123cba";

vB_Template::preRegister('vbcms_content_article_pr eview',array('testme' => $testme));

inside my vbcms_content_article_preview template, i have:

:{vb:raw testme}:

All I see is "::", the variable doesnt show.

----------------------------------------------------------

2) I want to process my logic for EACH article on the page. So I need a hook that gets fired multiple times, and allows me to send output to the template in question for each iteration.


I have paid support over at vbulletin.com, but they sent me over here anyways, as youse guys are the bomb.
----------------------------------------------------------

An example of this plugin, might be to show a small graphic for new articles, vs articles over a week old, vs articles over a month old.

Please give a hand, as Im ripping out what little hair i have left!!

Dead Eddie 07-19-2011 08:59 PM

If you're just doing it on the preview, try this:

Hook name: vbcms_article_populate_end

PHP Code:

if(self::VIEW_PREVIEW == $viewtype){
    
$view->custom='I am the very model of a modern major general';


Then, within the "vbcms_content_article_preview" template, your variable is {vb:raw custom}.

Carpesimia 07-19-2011 09:09 PM

Quote:

Originally Posted by Dead Eddie (Post 2222579)
If you're just doing it on the preview, try this:

Hook name: vbcms_article_populate_end

PHP Code:

if(self::VIEW_PREVIEW == $viewtype){
    
$view->custom='I am the very model of a modern major general';


Then, within the "vbcms_content_article_preview" template, your variable is {vb:raw custom}.


Excellent! That works.

Now, the next question. How do i find the node-id for the current article iteration? I believe that it is piece i am still missing.

Dead Eddie 07-19-2011 09:34 PM

PHP Code:

$this->getNodeId(); 

Although, you already have a wealth of information available to you about the article at this hook already. What do you need the node id for?

Lynne 07-19-2011 10:17 PM

(global_start is deprecated - do a search in your files and you will see this. So, it is not evaled at all in the CMS pages.)

Carpesimia 07-20-2011 12:01 AM

Quote:

Originally Posted by Dead Eddie (Post 2222593)
PHP Code:

$this->getNodeId(); 

Although, you already have a wealth of information available to you about the article at this hook already. What do you need the node id for?

Im using special tags to discern a special meaning for different articles. If you have the tag, I need to show a special graphic on the preview page. So I need the nodeid so I can check for the presence of the tag. If the tag exists, I'll fill in my var and the image will appear on the page.

This was the best way to do it and still remain non-intrusive.

--------------- Added [DATE]1311123733[/DATE] at [TIME]1311123733[/TIME] ---------------

Quote:

Originally Posted by Lynne (Post 2222614)
(global_start is deprecated - do a search in your files and you will see this. So, it is not evaled at all in the CMS pages.)

AH! Makes sense. Wish the support rep I had on the phone earlier told me that. He just agreed it should work, and sent me here.

Dead Eddie 07-20-2011 12:23 AM

You're talking about default, vBulletin tags? You'll actually need the contenttypeid/contentid, not the nodeid.

PHP Code:

$this->content->getContentTypeId();
$this->content->getContentId(); 

If you haven't found it yet...use the taggablecontent class. Won't save you a query...but it'll save you from rewriting one. :)

Carpesimia 07-20-2011 12:37 AM

Quote:

Originally Posted by Dead Eddie (Post 2222666)
You're talking about default, vBulletin tags? You'll actually need the contenttypeid/contentid, not the nodeid.

PHP Code:

$this->content->getContentTypeId();
$this->content->getContentId(); 

If you haven't found it yet...use the taggablecontent class. Won't save you a query...but it'll save you from rewriting one. :)

Actually hadnt tested yet, but I had assumed it was nodeid. Just hadnt gotten that far yet. Thanks! Where do i find info on the taggablecontent class? I have already written my query, but am all about doing things the proper way when possible.

Dead Eddie 07-20-2011 01:00 AM

Not sure if one way is more "proper" than the other, but here's what you're looking at...

PHP Code:

require_once DIR '/includes/class_taggablecontent.php';
$taggable vB_Taggable_Content_Item::create(vB::$vbulletin$this->content->getContentTypeId(), $this->content->getContentId(), $this->content);
$tag_list $taggable->fetch_existing_tag_list(); 

You can look at /includes/class_taggablecontent.php for more information on using the class.

nirvana43 10-30-2011 11:26 AM

For future referance :
If you want to get nodeId of all articles on that page then create a plugin at hook : vbcms_article_populate_start

And then below will get you nodeId of each article :
$this->content->getNodeId()

Note that it is content->getNodeId() and not node->getNodeId().

Cheers!
Aditya Hajare

P.S. I'm assuming you know all about pre-registering vars to templates etc. etc. Thats why i'm not writing this in details. But if you want sample code then lemme know. Cheers!


All times are GMT. The time now is 03:51 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.01130 seconds
  • Memory Usage 1,755KB
  • 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
  • (7)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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