Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 08-21-2012, 02:20 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Another Str_Replace Question (vB4 & vB3)

Hi everyone, I saw the other thread answered by Kh99 and Scanu..

I am working on a project, my plan is to build a Product, for example Bookmark-Buttons that I wanna add in POSTBIT and POSTBIT LEGACY! I have to the buttons "On top of the Signature" or simply replace the "Signature Start"! So far I have made this done with the help of a few friends for vB 3.8. And thanks to Scanu for his contribution and help the other day. Now I wanna publish my Products for vB4.x also! And I have 2 simple questions..

First my replacement code: (for vB3.8) worked perfect:
Code:
$replace = '$template_hook[postbit_signature_start]';
        $vbulletin->templatecache['postbit'] = str_replace($replace,$replace.fetch_template('MYCODE'),$vbulletin->templatecache['postbit']);
        $vbulletin->templatecache['postbit_legacy'] = str_replace($replace,$replace.fetch_template('MYCODE'),$vbulletin->templatecache['postbit_legacy']);


Question 1:
I have only made a few modifications, but dont know about the vb 4.x system yet. Now what should I change in my replacement code, to make the code fit on vBulletin 4.x! Obviously my vB3.8 code didnt work on vb 4.x

Here is the line where I wanna start my replacement in vB 4.x Postbit and Postbit Legacy:
Code:
{vb:raw template_hook.postbit_signature_start}


I have followed the other thread, where kh99 replied with:
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']);


I can see that this is 1 Template Change. How to do 2 changes in 2 different Templates, using 1 xml product. As you can see I have to replace Postbit and Postbit legacy... So I really hope I can get an exact same code or explanation for vB 4.x!

Thank you very much in advance,
Reply With Quote
  #2  
Old 08-21-2012, 03:44 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

  1. If you don't have vBulletin in debug mode, put it in debug mode so you don't have to edit the Xml by hand.
  2. Download product-extended_legacies. If you are running vB3, this will be required -- but do NOT make it a dependency. It won't install on vB4 because it's not needed there.
  3. PHP Code:
    $hookName 'postbit_signature_start';
    $template 'MYCODE';

    if (
    defined('MAJOR_VERSION') && MAJOR_VERSION == 3) {
        
    vB_Template::$convert[$template] = array('template' => "{$template}_LEGACY");
    }

    $templater vB_Template::create($template);
    $template_hook[$hookName] = $templater->render() . $template_hook[$hookName]; 

Extended Legacies lets you use the vB4 template syntax in vB3 so you don't have to write template code for each version.

First, what the code above does is set our hook name and vB4 template name. Then, it checks if you are running vB3. If you are, it will change the template from MYCODE to MYCODE_LEGACY (the vB3 equivalent) automatically. Otherwise, it will load the vB4 template MYCODE.

The above code should place your markup below posts but above the signature.
Attached Files
File Type: xml product-extended_legacies.xml (4.0 KB, 6 views)
Reply With Quote
Благодарность от:
ChiNa
  #3  
Old 08-21-2012, 05:15 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Amazing thing... Thank you so much, This will save me lots of time on vB 3.8,, You have really saved me lots of time and I am simply honored to have got some help from some one like your sir.

Now I have to surely understand vB4.x, befor I can try vB 4. stuff on vB3.8! I will later today release my version for vB3.8, and I will def let you know about my release for vB3.8. But so far the same product I have made for vB3.8, I am lost to do the same thing for vB4.x! And this was why I came to ask for help.

And about the Debut Mode, Yes Scanu, yet another amazing coder helped me the other day with it, and as you can see I am totally new to this. I will try work hard on the project and the tutorial you have showen me. And I will def give my best shot! Thank you very much.. Appreciated alot!

--------------- Added [DATE]1345593630[/DATE] at [TIME]1345593630[/TIME] ---------------

Hi again, I just finished the vB3.8 Product that I was talking about, the Postbit Start Replacemen, here is the thread maybe you would check it out:
https://vborg.vbsupport.ru/showthread.php?p=2358841

Thank you very much for your advice and your help!
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 05:33 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.03691 seconds
  • Memory Usage 2,202KB
  • Queries Executed 12 (?)
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
  • (3)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (1)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (1)postbit_attachment
  • (3)postbit_onlinestatus
  • (3)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete