View Full Version : Changing templates with plugins
Mrajp
12-14-2009, 06:37 PM
Just when I thought I had finally understood a small percentage of the vBulletin code, a completely new (but very powerful) template syntax has been released! :D
I have a small piece of code that adds an extra checkbox when a user is posting a reply. This ultimately adds some text to the message area and changes the prefix. Unfortunately with the new version, the page wont even load.
I've read some of the template articles and examined some 4.0 mods. However, they are at a level higher than my current vBulletin code comprehension.
Here is the code that is compatible with vB 3.8 using the "newreply_form_complete" hook:
$str = "<!-- Some comment in a template-->";
$replace = "<br />
<input type='checkbox' name='resolved' value='1' />Resolution?
";
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace,$vbulletin->templatecache['newreply']);
There is also another plugin hooked to "newreply_post_start" that massages the data. It probably isn't compatible either, but I'll cross that bridge when I get to it.
Is there still a way to perform the functionality of my current code? If so, could someone give me some guidance?
Lynne
12-14-2009, 06:42 PM
Is there a question here?
Mrajp
12-15-2009, 01:32 PM
Whoops! I just realized I forgot to ask one. Thanks Lynne!
Is there still a way to perform the functionality of my current code? If so, could someone give me some guidance?
Thanks in advance.
BBR-APBT
12-15-2009, 01:46 PM
It would be like this.
$str = "<!-- Some comment in a template-->";
$replace = "<br /><input type='checkbox' name='resolved' value='1' />Resolution?";
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace, $vbulletin->templatecache['newreply']);
Mrajp
12-15-2009, 07:22 PM
It would be like this.
$str = "<!-- Some comment in a template-->";
$replace = "<br /><input type='checkbox' name='resolved' value='1' />Resolution?";
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace, $vbulletin->templatecache['newreply']);
I don't mean to seem ignorant, but the only difference I see between your code and mine is that the $replace string is all on one line. Are you saying that vB 4.0 can only handle 1 line replacement strings?
The above code still doesn't work in vB 4.0
BBR-APBT
12-15-2009, 08:09 PM
I don't mean to seem ignorant, but the only difference I see between your code and mine is that the $replace string is all on one line. Are you saying that vB 4.0 can only handle 1 line replacement strings?
The above code still doesn't work in vB 4.0
With the proper hook location? process_templates_complete
Mrajp
12-17-2009, 07:55 AM
With the proper hook location? process_templates_complete
Well, I originally didn't have the hook location set to "process_templates_complete". However, even after changing the hook location, I get the following error message and the page does not load:
Parse error: syntax error, unexpected T_STRING in D:\wamp\othersites\beta\includes\class_core.php(39 17) : eval()'d code on line 104
I've hardcoded the replace string into the style just to verify that the HTML is correct. When hardcoded, the page loads without error and the checkbox appears.
Any Ideas?
BBR-APBT
12-17-2009, 02:03 PM
Can I see your exact code.
You can post the error all day long with out the code its no good.
Mrajp
12-17-2009, 06:16 PM
Most certainly,
Here is the section of the style 'newreply' with the comment
</div>
<vb:if condition="$show['additional_options']">
<h3 class="blockhead">{vb:rawphrase additional_options}</h3>
<div class="blockbody formcontrols">
<vb:if condition="$show['misc_options']">
<div class="blockrow">
<!-- Some Comment -->
<ul class="checkradio group">
<vb:if condition="$bbuserinfo['signature'] != ''">
<li>
<label for="cb_signature"><input type="checkbox" name="signature" value="1" id="cb_signature" tabindex="4" {vb:raw checked.signature} /> {vb:rawphrase show_your_signature}</label>
Here is my complete plugin code on the 'process_templates_complete' hook:
$str = "<!-- Some Comment -->";
$replace = "<br /><input type='checkbox' name='resolved' value='1' />Resolution?";
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace,$vbulletin->templatecache['newreply']);
I'm running vB 4.0 RC2.
Please let me know if you need any more information.
Thanks Again.
BBR-APBT
12-17-2009, 06:44 PM
Try this
$str = "<!-- Some Comment -->";
$replace = '<br /><input type="checkbox" name="resolved" value="1" />Resolution?';
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace,$vbulletin->templatecache['newreply']);
I switched the " and ' around.
ragtek
12-17-2009, 06:58 PM
My question is a little bit offtopic.
Can the new vB4 Template Mering be used for this?
http://www.vbulletin.com/forum/entry.php?2350-vB-4-0-Template-Merging-and-3-Way-Comparison
Anybody tried this?
BBR-APBT
12-17-2009, 07:29 PM
My question is a little bit offtopic.
Can the new vB4 Template Mering be used for this?
http://www.vbulletin.com/forum/entry.php?2350-vB-4-0-Template-Merging-and-3-Way-Comparison
Anybody tried this?
It should stay there with upgrade but I don't trust it my self as I haven't tested that feature out enough yet.
Mrajp
12-18-2009, 08:28 AM
Try this
$str = "<!-- Some Comment -->";
$replace = '<br /><input type="checkbox" name="resolved" value="1" />Resolution?';
$vbulletin->templatecache['newreply'] = str_replace($str,$str.$replace,$vbulletin->templatecache['newreply']);
I switched the " and ' around.
Switching the string identifiers fixed the problem. Thank you so very much! :)
My question is a little bit offtopic.
Can the new vB4 Template Mering be used for this?
http://www.vbulletin.com/forum/entry.php?2350-vB-4-0-Template-Merging-and-3-Way-Comparison
Anybody tried this?
This looks interesting, I'm going to have a lot of style changes to make and I may try this.
ragtek
12-18-2009, 08:33 AM
If it's not working, try tms!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.