The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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? |
Благодарность от: | ||
mokujin |
#2
|
|||
|
|||
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); |
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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.
|
#5
|
|||
|
|||
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. |
#6
|
|||
|
|||
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; |
#7
|
|||
|
|||
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? |
#8
|
|||
|
|||
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.
|
#9
|
|||
|
|||
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
|
#10
|
|||
|
|||
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. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|