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 07-19-2011, 07:22 PM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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:reRegister('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!!
Reply With Quote
  #2  
Old 07-19-2011, 08:59 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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}.
Reply With Quote
  #3  
Old 07-19-2011, 09:09 PM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dead Eddie View Post
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.
Reply With Quote
  #4  
Old 07-19-2011, 09:34 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 07-19-2011, 10:17 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

(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.)
Reply With Quote
  #6  
Old 07-20-2011, 12:01 AM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dead Eddie View Post
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 View Post
(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.
Reply With Quote
  #7  
Old 07-20-2011, 12:23 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 07-20-2011, 12:37 AM
Carpesimia Carpesimia is offline
 
Join Date: Jun 2011
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dead Eddie View Post
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.
Reply With Quote
  #9  
Old 07-20-2011, 01:00 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 10-30-2011, 11:26 AM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
Благодарность от:
Lynne
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 07:03 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.07128 seconds
  • Memory Usage 2,272KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete