View Full Version : [SOLVED]more than one replacement, same template on plugin
Dr.CustUmz
04-10-2016, 02:31 AM
im trying to do multiple edits to showthread quickreply. individually these work, but when i do more than one only the first one works.
how can i make more than one change?
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('dr c_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
MarkFL
04-10-2016, 02:36 AM
Without knowing what's in the search and replace variables, it's hard to say. Have you tried reversing the order of the two lines of code?
I'm thinking the first line makes a change in the template code whereby the second line no longer finds the search text that was there before the first line changed it.
Dr.CustUmz
04-10-2016, 02:47 AM
its a little sloppy right now, but here it is:
$drcidl_inc = '<!-- / CSS Stylesheet -->';
$drcidl_cr = '$vbphrase[powered_by_vbulletin]';
$drcrb_hd = '<textarea name=\"message\" id=\"{$editorid}_textarea\" rows=\"10\" cols=\"60\" style=\"width:100%; height:{$editor_height}px\" tabindex=\"1\" dir=\"$stylevar[textdirection]\"></textarea>';
$find = '<textarea name=\"message\" id=\"{$editorid}_textarea\"';
$replace = '<textarea class=\"form-control comment-form-textarea\" name=\"message\" id=\"{$editorid}_textarea\"';
if(strpos($vbulletin->templatecache['headinclude'],$drcidl_inc) !==false)$vbulletin->templatecache['headinclude'] = str_replace($drcidl_inc,fetch_template('drc_iiu_cs s').$drcidl_inc,$vbulletin->templatecache['headinclude']);
else $vbulletin->templatecache['headinclude'] .= fetch_template('drc_iiu_css');
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('dr c_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['footer'] = str_replace($drcidl_cr,$drcidl_cr.fetch_template(' drc_iiu_js'),$vbulletin->templatecache['footer']);
after reading your comment I realized I am finding the same part for both finds, although I am not changing it so I dont see how that could be causing an issue.
grouping the causes and effects together to help you see better:
$drcrb_hd = '<textarea name=\"message\" id=\"{$editorid}_textarea\" rows=\"10\" cols=\"60\" style=\"width:100%; height:{$editor_height}px\" tabindex=\"1\" dir=\"$stylevar[textdirection]\"></textarea>';
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('dr c_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
is just adding a template after that line.
AND
$find = '<textarea name=\"message\" id=\"{$editorid}_textarea\"';
$replace = '<textarea class=\"form-control comment-form-textarea\" name=\"message\" id=\"{$editorid}_textarea\"';
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
adds a class to textarea
and boom I caught it, might have fixed it lol, one sec for testing =)
--------------- Added 1460263784 at 1460263784 ---------------
yup that addition of the class was the issue =)
switching the order to
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('dr c_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
solved this.
however is there a better way to do this?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.