Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-14-2009, 06:37 PM
Mrajp Mrajp is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!

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?
Reply With Quote
  #2  
Old 12-14-2009, 06:42 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a question here?
Reply With Quote
  #3  
Old 12-15-2009, 01:32 PM
Mrajp Mrajp is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 12-15-2009, 01:46 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']);
Reply With Quote
  #5  
Old 12-15-2009, 07:22 PM
Mrajp Mrajp is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BBR-APBT View Post
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
Reply With Quote
  #6  
Old 12-15-2009, 08:09 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mrajp View Post
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
Reply With Quote
  #7  
Old 12-17-2009, 07:55 AM
Mrajp Mrajp is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BBR-APBT View Post
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?
Reply With Quote
  #8  
Old 12-17-2009, 02:03 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can I see your exact code.

You can post the error all day long with out the code its no good.
Reply With Quote
  #9  
Old 12-17-2009, 06:16 PM
Mrajp Mrajp is offline
 
Join Date: Mar 2005
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 12-17-2009, 06:44 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06980 seconds
  • Memory Usage 2,260KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete