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 11-09-2012, 05:07 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hook to modify article content

Hi there. I need to modify the article content output for our articles based on preset criteria. I believe the hook I need is vbcms_article_populate_start, but 'pagetext' is protected so I can't modify it.

Where should I be looking in order to accomplish what I need?
Reply With Quote
Благодарность от:
mokujin
  #2  
Old 11-09-2012, 05:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't have much experience with the CMS, but maybe try something like

Code:
$pagetext = $this->content->getPageText();
// do stuff to $pagetext here
$this->content->setProperty('pagetext', $pagetext);
Reply With Quote
  #3  
Old 11-09-2012, 05:51 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah - I didn't know about setProperty. I'll investigate that in a bit.

Thanks!

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

Unfortunately, setProperty is also protected and I can't do anything with it.

Fatal error: Call to protected method vB_Item::setProperty() from context 'vBCms_Content_Article'

Sorry for what are surely stupid questions - This is my first time hooking into the CMS and it's very new to me.
Reply With Quote
  #4  
Old 11-09-2012, 05:56 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I just decided I should try it myself and got the same error. Don't worry, they aren't stupid questions, but unfortunately I don't know the answers. I'll see if I can figure out something else - it might be possible to replace the content object with a new one.
Reply With Quote
  #5  
Old 11-09-2012, 06:05 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Edit: oh, no, you might not want to do the setInfo thing I posted - it seems to be changing the articles even after I disable the plugin. It might just be a cache, I'm not sure, but I don't want you to risk changing anything permanently.

Yep, the code I posted here then deleted seems to have permanently changed the content of some of my articles (but it's just a test system). That may or may not be a problem for you, maybe it's OK with you if they're chnaged in the db.
Reply With Quote
  #6  
Old 11-09-2012, 06:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I really hope none of your articles got messed up by the last thing I posted, but I think this works: try using hook vbcms_article_populate_end and something like this:

Code:
// Make changes to $pagetext var, then
$view->pagetext = $pagetext;
Reply With Quote
  #7  
Old 11-09-2012, 06:35 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I actually figured that one out right before you posted it. The problem is that it loses all bbcode formatting when I use it. I'mn trying to walk through the PHP code where it renders the bbcode, but so far haven't come up with what I need.

We're definitely on the right path though.

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

It looks like
Code:
$this->rendered['pages'][$this->parameters['page']];
is the rendered view, but that doesn't do any good. I think we need to get the raw pagetext (Stored in $pagetext), do our processing to it, and then run it through the renderer and assign it to $view->pagetext. I just don't know how we can parse the bbcode, line breaks, smileys, etc....

Is there a built-in vb function that does all of that parsing that we can just call?
Reply With Quote
  #8  
Old 11-09-2012, 07:12 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, sorry again. I tried it with an article that only had one sentence so I didn't notice the bbcode problem. But you obviously need someone who knows about it instead of someone to help you guess at things. It might take a while though, I don't think everyone visits here every day.
Reply With Quote
  #9  
Old 11-09-2012, 07:19 PM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well you've definitely been a huge help, for sure. Hopefully someone else can chime in soon with the solution or I can figure it out with some more head banging
Reply With Quote
  #10  
Old 11-09-2012, 07:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I did think of another possible approach: use hook template_render_ouput and do something like:

Code:
if ($this->template == 'vbcms_content_article_page')
{
    // do something to $pagetext here.
}

At that point $pagetext will be html.
Reply With Quote
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 06:23 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.05557 seconds
  • Memory Usage 2,253KB
  • 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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete