vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Changing templates with plugins (https://vborg.vbsupport.ru/showthread.php?t=230202)

Mrajp 12-14-2009 06:37 PM

Changing templates with plugins
 
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:

Code:

$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.
Code:

$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

Quote:

Originally Posted by BBR-APBT (Post 1931102)
It would be like this.
Code:

$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

Quote:

Originally Posted by Mrajp (Post 1931336)
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

Quote:

Originally Posted by BBR-APBT (Post 1931359)
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:

Code:

Parse error: syntax error, unexpected T_STRING in D:\wamp\othersites\beta\includes\class_core.php(3917) : 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
Code:

    </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:

Code:

$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
Code:

$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.


All times are GMT. The time now is 05:55 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
  • Page Generation 0.01695 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete