The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to str_replace in vb4
I use a code for VB3 and I want to convert it to work on vb4.
Code:
$myput = '<!-- message area -->'; $vbulletin->templatecache['newthread'] = str_replace($myput,$myput.fetch_template('new_posting_newthread'),$vbulletin->templatecache['newthread']); |
#2
|
||||
|
||||
Quote:
PHP Code:
|
Благодарность от: | ||
Easy5s.net |
#3
|
|||
|
|||
in vB 4
PHP Code:
|
Благодарность от: | ||
Easy5s.net |
#4
|
|||
|
|||
The problem is that in vb3, templates were stored as if they were a php double quoted string without the quotes, so you could just replace part of one cached template with another entire template. In vb4, they're stored as php code that when eval()'d sets the $final_rendered variable to the html string to be output. So if you think about that, just inserting another template doesn't work - you end up with invalid php code.
In any case, you could try this: Code:
$myput = '<!-- message area -->'; $replace = '\'; $final_rendered .= \'' . $myinput . substr(fetch_template('new_posting_newthread'), 19) . ' $final_rendered .= \''; $vbulletin->templatecache['newthread'] = str_replace($myput,$replace,$vbulletin->templatecache['newthread']); Edit: what badshah posted above is obviously simpler and will work if you haven't used any variables from the newthread template. |
#5
|
|||
|
|||
thank all but <!-- message area --> not in the temp newthread of the vB4 which only vbb3
|
#6
|
|||
|
|||
Very helpfull, Thank you all of you for answering, I have learned a lot on this one!
|
#7
|
|||
|
|||
Quote:
You could try this: change the hook location to newthread_form_complete and use this code: Code:
$templater = vB_Template::create('new_posting_newthread'); $messagearea = $templater->render() . $messagearea; |
#8
|
|||
|
|||
Quote:
"You must 'Like' someone else's post before liking any more by kh99". |
#9
|
|||
|
|||
That's ok, you'd probably want to wait to see if it works.
|
#10
|
|||
|
|||
Ok, it works, thank you again, but why I can not click like for you?
"You must 'Like' someone else's post before liking any more by kh99" |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|