Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 01-21-2010, 10:00 PM
kermit2 kermit2 is offline
 
Join Date: Jun 2008
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default CMS Hooks

Hi all,

I'm toying around, trying to modify the content of CMS articles when they are displayed (ie I don't want to edit the article saved in the database, just as it's displayed). On the forums, I'd use something like threadbit_process, but I'm having trouble finding a similar hook for the CMS (I'm using 4.0.0 at the moment).

I did wonder about hooking into another location further down, after the various template parts had been linked up, before the final output was sent to the browser (in which case my code would be acting on the whole html page, rather than the html for the CMS article). Does that sound like a workable solution? I was having trouble finding the most suitable hook for that too

Cheers!
Reply With Quote
  #2  
Old 01-21-2010, 10:08 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are currently 12 hooks available for use in the CMS.

Code:
<hook>vbcms_widgetdm_start</hook>
<hook>vbcms_widgetdm_presave</hook>
<hook>vbcms_widgetdm_postsave</hook>
<hook>vbcms_widgetdm_postdelete</hook>
<hook>vbcms_article_defaultcontent_start</hook>
<hook>vbcms_article_defaultcontent_end</hook>
<hook>vbcms_articleblog_presave</hook>
<hook>vbcms_articlepost_presave</hook>
<hook>vbcms_article_populate_start</hook>
<hook>vbcms_article_populate_end</hook>
<hook>vbcms_article_save_start</hook>
<hook>vbcms_article_save_end</hook>
For your question you would want to use the following hook:
Code:
<hook>vbcms_article_populate_start</hook>
Now you have to figure out how the output works. and find a way to do preg_match or preg_replace, or what ever code you may choose to us.
Reply With Quote
  #3  
Old 01-22-2010, 08:51 AM
kermit2 kermit2 is offline
 
Join Date: Jun 2008
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. I'd tried vbcms_article_populate_end I think, but nice to have confirmation of what I should be using.

Bit of a problem though: none of the code in my plugin is being executed when I use that hook (my code was a simple print_r($GLOBALS)). I found the hook location in packages/vbcms/content/article.php, and immediately after:

($hook = vBulletinHook::fetch_hook('vbcms_article_populate_ start')) ? eval($hook) : false;

, I tried printing $hook. It's always empty.

Next I added

DEVDEBUG("Calling Hook $hookname")

just after

public static function fetch_hook($hookname = false)
{

in includes/class_hook.php. That confirmed that vbcms_article_populate_end was being called. So it seems the problem is that vbcms_article_populate_end doesn't exist in $pluginlist. I've tried dumping that array, and don't see any vbcms_* hooks in there.

Am I missing something stupidly obvious? I did wonder if there was now the ability to turn plugins off for just the CMS, but can't see that option in ACP
Reply With Quote
  #4  
Old 01-23-2010, 06:49 PM
kermit2 kermit2 is offline
 
Join Date: Jun 2008
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Problem solved (well, explained anyway). vbcms_article_populate_start (and others) are defined in xml as admin only. Seems this has been fixed in 4.0.1. There's a discussion here: http://www.vbulletin.com/forum/proje...?issueid=33246
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:16 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.03714 seconds
  • Memory Usage 2,179KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • 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