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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2016, 03:06 AM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default replacing everything between a div in a template

Say I want to replace this snippit in showthread_quickreply:

Code:
<div class="controlbar" style="padding-$stylevar[right]:8px">
	<fieldset style="border:0px; padding:0px; margin:0px">
	<if condition="$show['qr_require_click']">
	<textarea name="message" id="{$editorid}_textarea" rows="10" cols="60" style="width:100%; height:{$editor_height}px" tabindex="1" dir="$stylevar[textdirection]" disabled="disabled">$vbphrase[click_quick_reply_icon]</textarea>
	<else />
	<textarea name="message" id="{$editorid}_textarea" rows="10" cols="60" style="width:100%; height:{$editor_height}px" tabindex="1" dir="$stylevar[textdirection]"></textarea>
	</if>
	</fieldset>
	<!--width:$stylevar[messagewidth]-->
</div>
I want to replace it with my own template.

I've tried a few combinations similar to:
Code:
$test = '<div class=\"controlbar\" style=\"padding-$stylevar[right]:8px\">.*</div>';
$vbulletin->templatecache['showthread_quickreply'] = str_replace($test,fetch_template('drc_iiu_test'),$vbulletin->templatecache['showthread_quickreply']);
but I can't get any result to display, is there a way to replace everything in between that div?
Reply With Quote
  #2  
Old 04-10-2016, 05:48 AM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Don't escape the double quotes, it isn't required in the test string because the string is enclosed in single quotes.
Reply With Quote
  #3  
Old 04-10-2016, 01:29 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$test = '<div class="controlbar" style="padding-$stylevar[right]:8px">.*</div>';
$vbulletin->templatecache['showthread_quickreply'] = str_replace($test,fetch_template('drc_iiu_test'),$vbulletin->templatecache['showthread_quickreply']);
still nothing =/
Reply With Quote
  #4  
Old 04-10-2016, 02:05 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's what I do when I am trying to edit a template via a plugin and experiencing difficulty...first I look at the template code before any alterations at runtime, and copy/paste that code into a text editor.

Next, I manually edit the template to make the desired change, and look at this at runtime and copy/paste that below the previous paste into my text editor.

Then, revert the template back to its original state.

Now I have the desired before/after to inspect in my text editor, and it is easier to see what I need to do to make the desired change using PHP.
Reply With Quote
Благодарность от:
Dr.CustUmz
  #5  
Old 04-10-2016, 04:35 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i went about doing it pretty much that way lol, with a bunch of minor changes

things are not named the final name this is just my build procedure lol, i know... sloppy =)
it'll be sexy and make sence in the end
example:
Code:
//showthread_quickreply

$drcrb_hd = '</fieldset>';
$find = '<textarea name=\"message\" id=\"{$editorid}_textarea\"';
$replace = '<textarea class=\"form-control comment-form-textarea\" name=\"message\" id=\"{$editorid}_textarea\"';
$find2 = '<div class=\"controlbar\"';
$replace2 = '<div class=\"controlbar upload-enabled\"';

$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,fetch_template('drc_iiu_below_txtarea').$drcrb_hd,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find2,$replace2,$vbulletin->templatecache['showthread_quickreply']);

//newthread
$find6 = '$newpost[message]</textarea>';
$find4 = '<textarea name=\"message\" id=\"{$editorid}_textarea\"';
$replace4 = '<textarea class=\"form-control comment-form-textarea\" name=\"message\" id=\"{$editorid}_textarea\"';
$find3 = '<td class=\"controlbar\">';
$replace3 = '<td class=\"controlbar upload-enabled\">';
$vbulletin->templatecache['editor_toolbar_on'] = str_replace($find6,$find6.fetch_template('drc_iiu_below_txtarea'),$vbulletin->templatecache['editor_toolbar_on']);
$vbulletin->templatecache['editor_toolbar_on'] = str_replace($find4,$replace4,$vbulletin->templatecache['editor_toolbar_on']);
$vbulletin->templatecache['editor_toolbar_on'] = str_replace($find3,$replace3,$vbulletin->templatecache['editor_toolbar_on']);
and I could fully replace the template with my copied changes like:
Code:
$vbulletin->templatecache['editor_toolbar_on'] = $vbulletin->templatecache['drc_iiu_editor_toolbar_on'];
I just thought, "hey can I just change everything in between a div, that'd be so much easier and the user wouldn't have to worry about if my complete change is going to screw up their template."

but grabbing things that SHOULD be there no matter how custom a theme is ...SHOULD work for everyone lol
Reply With Quote
  #6  
Old 04-13-2016, 06:11 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

preg_replace -_- lmao, too bad the products done now, will come in handy in the future though =)
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 03:40 AM.


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.04086 seconds
  • Memory Usage 2,219KB
  • 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
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (1)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete