vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   preg_replace if condition in template (https://vborg.vbsupport.ru/showthread.php?t=317725)

Dr.CustUmz 03-10-2015 10:52 PM

preg_replace if condition in template
 
im trying to replace everything inside of an if condition in the quick reply template

my parse_template code is:
Code:

$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:

Code:

$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


All times are GMT. The time now is 12:53 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00951 seconds
  • Memory Usage 1,709KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete