Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2011, 11:32 PM
SorentoUltimate's Avatar
SorentoUltimate SorentoUltimate is offline
 
Join Date: Jul 2009
Location: Moschato, Athens, Greece
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Find Replace into Template PlugIn Code

Hi all,

in vb3 i use that code to make changes to templates (parse_templates hook)

PHP Code:
    require_once(DIR '/includes/adminfunctions_template.php'); 

    
$string_fnd compile_template('<if condition="$show[\'contactus\']"><a href="$vboptions[contactuslink]" rel="nofollow" accesskey="9">$vbphrase[contact_us]</a> -</if>'); 
    
$string_add fetch_template('terrabyter_about_us_footer_link'); 
    
$vbulletin->templatecache['footer'] = str_replace($string_fnd$string_add "\r\n" $string_fnd$vbulletin->templatecache['footer']); 

    unset(
$string_fnd$string_add); 
how i do the same in vb4 ?

Thanks in Advance
SorentoUltimate

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

can someone help me on the above?

i need to make automatic template edits into plugins with code.
Reply With Quote
  #2  
Old 06-04-2011, 04:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you tried this in vb4? I haven't tried it but all the same functions/variables seem to be there.
Reply With Quote
  #3  
Old 06-04-2011, 04:32 PM
SorentoUltimate's Avatar
SorentoUltimate SorentoUltimate is offline
 
Join Date: Jul 2009
Location: Moschato, Athens, Greece
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i try that code:
PHP Code:
      $find_string  fetch_template('greeklish2greek_SHOWTHREAD_fnd');
      
$repl_string  fetch_template('greeklish2greek_SHOWTHREAD_rpl');
      
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find_string$repl_string$vbulletin->templatecache['SHOWTHREAD']); 
but not work, with error:

Quote:
Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: greeklish2greek_SHOWTHREAD_fnd in [path]/includes/functions.php on line 4097

Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: greeklish2greek_SHOWTHREAD_rpl in [path]/includes/functions.php on line 4097
Reply With Quote
  #4  
Old 06-04-2011, 05:08 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne has a modification here you should view the .xml and see where your going wrong, will help you visualize how it's done in vB4 .

https://vborg.vbsupport.ru/showthread.php?t=229290
Reply With Quote
  #5  
Old 06-04-2011, 09:30 PM
SorentoUltimate's Avatar
SorentoUltimate SorentoUltimate is offline
 
Join Date: Jul 2009
Location: Moschato, Athens, Greece
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi again,

Here are the Templates and Plugin Code to help me solve the problem :

a.Template "greeklish2greek_SHOWTHREAD_fnd"

Code:
    <div class="blockfoot actionbuttons">
        <div class="group">
            <span id="qr_posting_msg" class="hidden">
                <img src="{vb:stylevar imgdir_misc}/progress.gif" alt="{vb:rawphrase posting_quick_reply_please_wait}" />&nbsp;<strong>{vb:rawphrase posting_quick_reply_please_wait}</strong>
            </span>
            <vb:if condition="$show['fb_publishcheckbox']">
                {vb:raw fbpublishcheckbox}
            </vb:if>
            <input type="submit" class="button" value="{vb:rawphrase post_quick_reply}" accesskey="s" title="(Alt + S)" name="sbutton" tabindex="1" id="qr_submit" onclick="clickedelm = this.value" />
            <input type="submit" class="button" value="{vb:rawphrase go_advanced}" accesskey="x" title="(Alt + X)" name="preview" tabindex="1" id="qr_preview" onclick="clickedelm = this.value" />
            <input type="reset" id="qr_cancelbutton" class="button" style="display:none;" value="{vb:rawphrase cancel}" accesskey="c" title="(Alt + C)" name="cancel" tabindex="4" onclick="qr_reset();" />
        </div>
    </div>
_

b.Template "greeklish2greek_SHOWTHREAD_rpl"

Code:
    <div class="blockfoot actionbuttons">
        <div class="group">
            <span id="qr_posting_msg" class="hidden">
                <img src="{vb:stylevar imgdir_misc}/progress.gif" alt="{vb:rawphrase posting_quick_reply_please_wait}" />&nbsp;<strong>{vb:rawphrase posting_quick_reply_please_wait}</strong>
            </span>
            <vb:if condition="$show['fb_publishcheckbox']">
                {vb:raw fbpublishcheckbox}
            </vb:if>
            <input type="button" class="button" value="{vb:rawphrase greeklish2greek}" accesskey="g" title="(Alt + G)" name="greeklish2greek" tabindex="1" onClick="greeklish2greek_message('vbform', 'quick_reply', '2');" />
            <input type="submit" class="button" value="{vb:rawphrase post_quick_reply}" accesskey="s" title="(Alt + S)" name="sbutton" tabindex="1" id="qr_submit" onclick="clickedelm = this.value" />
            <input type="submit" class="button" value="{vb:rawphrase go_advanced}" accesskey="x" title="(Alt + X)" name="preview" tabindex="1" id="qr_preview" onclick="clickedelm = this.value" />
            <input type="reset" id="qr_cancelbutton" class="button" style="display:none;" value="{vb:rawphrase cancel}" accesskey="c" title="(Alt + C)" name="cancel" tabindex="4" onclick="qr_reset();" />
        </div>
    </div>
_


c.Part of Template "SHOWTHREAD"

Code:
.....
<vb:if condition="$show['quickreply']">
<div id="qr_defaultcontainer" class="blockfoot floatcontainer qrcontainer<vb:if condition="$show['qr_require_click']"> qr_require_click</vb:if>">
<form class="vbform" name="quick_reply" id="quick_reply" method="post" action="{vb:raw $vboptions.vbforum_url}{vb:if "$vboptions['vbforum_url']", '/', ''}newreply.php?do=postreply&amp;t={vb:raw threadid}"
    onsubmit="return qr_prepare_submit(this, {vb:raw vboptions.postminchars});">
    <div id="qr_error_tbody" class="block errorblock hidden">
        <h3 class="blockhead">{vb:rawphrase errors}</h3>
        <div class="blockbody formcontrols">
            <h3 class="blocksubhead">{vb:rawphrase errors_occured_when_submitted}</h3>
            <div class="blockrow error" id="qr_error_td"></div>
        </div>
        <div class="blockfoot actionbuttons"><div class="group"><a href="javascript://" class="textcontrol" onclick="return qr_hide_errors()">{vb:rawphrase okay}</a></div></div>
    </div>

    <div class="fullwidth"><h3 id="quickreply_title" class="blockhead"><img src="{vb:stylevar imgdir_button}/reply_40b.png" alt="{vb:rawphrase quick_reply}" style="float:{vb:stylevar left};padding-{vb:stylevar right}:{vb:stylevar padding}"/> {vb:rawphrase quick_reply}<a name="quickreply"></a> <img style="display:none" id="progress_newreplylink_bottom" src="{vb:stylevar imgdir_misc}/progress.gif"  alt="" /></h3></div>
    <div class="wysiwyg_block">
    <div class="blockbody formcontrols">
        <div class="blockrow">
            {vb:raw messagearea}
        </div>
        <vb:if condition="$bbuserinfo['signature']">
        <div class="blockrow">
            <ul class="checkradio group">
                <li><label for="cb_signature">
                    <input type="checkbox" name="signature" id="cb_signature" value="1" checked="checked" tabindex="1" />
                    {vb:rawphrase show_your_signature}
                </label></li>
            </ul>
        </div>
        </vb:if>
        <vb:if condition="$show['openclose']">
        <div class="openclose">
            <ul class="checkradio">
                <li><label for="cb_openclose">
                    <input type="checkbox" name="openclose" id="cb_openclose" value="1" tabindex="1" />
                    <vb:if condition="$show['closethread']">{vb:rawphrase close_this_thread}<vb:else />{vb:rawphrase reopen_this_thread}</vb:if>
                </label></li>
            </ul>
        </div>
        </vb:if>
    </div>

    <div class="blockfoot actionbuttons">
        <div class="group">
            <span id="qr_posting_msg" class="hidden">
                <img src="{vb:stylevar imgdir_misc}/progress.gif" alt="{vb:rawphrase posting_quick_reply_please_wait}" />&nbsp;<strong>{vb:rawphrase posting_quick_reply_please_wait}</strong>
            </span>
            <vb:if condition="$show['fb_publishcheckbox']">
                {vb:raw fbpublishcheckbox}
            </vb:if>
            <input type="submit" class="button" value="{vb:rawphrase post_quick_reply}" accesskey="s" title="(Alt + S)" name="sbutton" tabindex="1" id="qr_submit" onclick="clickedelm = this.value" />
            <input type="submit" class="button" value="{vb:rawphrase go_advanced}" accesskey="x" title="(Alt + X)" name="preview" tabindex="1" id="qr_preview" onclick="clickedelm = this.value" />
            <input type="reset" id="qr_cancelbutton" class="button" style="display:none;" value="{vb:rawphrase cancel}" accesskey="c" title="(Alt + C)" name="cancel" tabindex="4" onclick="qr_reset();" />
        </div>
    </div>

    </div>
    <input type="hidden" name="fromquickreply" value="1" />
    <input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
    <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
    <input type="hidden" name="do" value="postreply" />
    <input type="hidden" name="t" value="{vb:raw threadid}" id="qr_threadid" />
    <input type="hidden" name="p" value="{vb:raw qrpostid}" id="qr_postid" />
    <input type="hidden" name="specifiedpost" value="0" id="qr_specifiedpost" />
    <input type="hidden" name="parseurl" value="1" />
    <input type="hidden" name="loggedinuser" value="{vb:raw bbuserinfo.userid}" />
    <input type="hidden" name="posthash" value="" />
    <input type="hidden" name="poststarttime" value="" />

<vb:if condition="!is_browser('ie') AND $show['wysiwyg']">
    <!-- Mozilla work around for focusing on QR in WYSIWYG mode -->
    <div id="qr_scroll"></div>
</vb:if>

</form>
</div>

</vb:if>
.....
_

d.Plugin "parse_templates" Code

Code:
$find_string = vB_Template::fetch_template_raw('greeklish2greek_SHOWTHREAD_fnd');
$repl_string = vB_Template::fetch_template_raw('greeklish2greek_SHOWTHREAD_rpl');
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find_string, $repl_string, $vbulletin->templatecache['SHOWTHREAD']);
_

but not work, i need your help !!!!
Reply With Quote
  #6  
Old 06-06-2011, 10:03 AM
SorentoUltimate's Avatar
SorentoUltimate SorentoUltimate is offline
 
Join Date: Jul 2009
Location: Moschato, Athens, Greece
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any help???????????
Reply With Quote
  #7  
Old 06-06-2011, 12:37 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?p=2204110#post2204110" target="_blank">https://vborg.vbsupport.ru/showt...10#post2204110</a>
Reply With Quote
  #8  
Old 06-06-2011, 02:04 PM
SorentoUltimate's Avatar
SorentoUltimate SorentoUltimate is offline
 
Join Date: Jul 2009
Location: Moschato, Athens, Greece
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Boofo,

i try that but not work

Code:
      $find_string = '';
      $repl_string = '';

      $parser          = new vB_TemplateParser(vB_Template::fetch_template_raw('greeklish2greek_SHOWTHREAD_fnd'));
      $parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
      $find_string     = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));

      $parser          = new vB_TemplateParser(vB_Template::fetch_template_raw('greeklish2greek_SHOWTHREAD_rpl'));
      $parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
      $repl_string     = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));
      
      $vbulletin->templatecache['SHOWTHREAD'] = str_replace($find_string, $repl_string, $vbulletin->templatecache['SHOWTHREAD']);
_

any idea what i'm doing wrong?
Reply With Quote
  #9  
Old 06-06-2011, 02:13 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use the code EXACTLY as I posted. You can't change the position and syntax of the lines to what you want them to be. Just add your code to find and replace where I showed you in red. The template name is all you should be changing.
Reply With Quote
Reply


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 08:10 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.07738 seconds
  • Memory Usage 2,276KB
  • Queries Executed 11 (?)
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
  • (5)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete