![]() |
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? |
I don't have much experience with the CMS, but maybe try something like
Code:
$pagetext = $this->content->getPageText(); |
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. |
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.
|
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. |
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 |
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 there a built-in vb function that does all of that parsing that we can just call? |
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.
|
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 :)
|
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') At that point $pagetext will be html. |
When was template_render_output introduced? Because I don't have that hook available here. All I've got is template_compile
|
Oh, right - that was just added with 4.2.0. I guess if you wanted to you could add it manually, then if you ever update to 4.2.0 it will continue to work. (Of course if you ever restore the files of the version you have now, it would break).
|
Yeah, I'll give that a shot. This site is definitely not able to be upgraded right now, so manually adding the hook may be our best bet.
Thanks for your help. Hopefully this works for us. |
All times are GMT. The time now is 11:01 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|