PDA

View Full Version : preg_replace if condition in template


Dr.CustUmz
03-10-2015, 10:52 PM
im trying to replace everything inside of an if condition in the quick reply template

my parse_template code is:
$vbulletin->templatecache['showthread_quickreply'] = preg_replace("/<if condition=\"$show\['qr_require_click'\]\">(.*)<\/if>/",fetch_template('drc_ac'),$vbulletin->templatecache['showthread_quickreply']);

yet im not getting any results, i have tried many ways and im not getting anywhere, although i am able to replace the whole template using:

$vbulletin->templatecache['showthread_quickreply'] = fetch_template('drc_ac');

but thats not what i want to do =/

kh99
03-10-2015, 11:28 PM
The problem is that what's in $vbulletin->templatecache[] is the compiled template, which is php code that prints out the html when it's eval()'d. That means you won't match the template <if tags because they aren't there. If you can match something that doesn't include the 'if' that might make it easier. Otherwise it's probably a good idea to look in the template table in the database where title='showthread_quickreply' (you want to look at the 'template' column), or just print out what's in the templatecache.

Dr.CustUmz
03-11-2015, 12:02 AM
thanks kev, im grabbing the <fieldset(.+?)<\/fieldset> now and its working great =) just got to be sure to include the if conditions in my template now which is no problem