vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   CMS Hooks (https://vborg.vbsupport.ru/showthread.php?t=233793)

kermit2 01-21-2010 10:00 PM

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!

BBR-APBT 01-21-2010 10:08 PM

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.

kermit2 01-22-2010 08:51 AM

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

kermit2 01-23-2010 06:49 PM

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


All times are GMT. The time now is 01:01 AM.

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.00921 seconds
  • Memory Usage 1,718KB
  • 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
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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