vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   process_template_conditionals doesn't work (https://vborg.vbsupport.ru/showthread.php?t=148680)

harmor19 06-01-2007 04:54 PM

process_template_conditionals doesn't work
 
I am planning on using the function 'process_template_conditionals()' in a script I'm making for vBulletin. It's returning "Test" even though the conditional should return false.

PHP Code:

require_once(DIR '/includes/adminfunctions_template.php');

$custom "<if condition='1 == 0'>Test</if>";

$results process_template_conditionals($custom);
echo 
$results


Adrian Schneider 06-01-2007 05:20 PM

Use single outer quotes instead of double... (so the condition is enclosed in double quotes). I haven't looked at the function, but I'm pretty sure that's how they are parsed.

PHP Code:

require_once(DIR '/includes/adminfunctions_template.php');

$custom '<if condition="1 == 0">Test</if>';

$results process_template_conditionals($custom);
var_dump($results); 


harmor19 06-01-2007 05:28 PM

It doesn't make a difference.

This Works

PHP Code:

require_once(DIR '/includes/adminfunctions_template.php');

$tt $db->query_first("SELECT * FROM ah_media WHERE mediaid = '1' ");
$done compile_template($getfield['fieldXX']);

eval(
'$show = "' $done '" ;');
echo 
$show

I tested it out and added die(); in the column and it parses it as text :)

I'm not that good when it comes to writing tutorials but can you understand it OK?


================================================== ==============
This tutorial will show you how to return data from a column you've created and parse template conditionals.

PHP Code:

<?php

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''my_script'); 

// #################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');

//You must include this in order to parse HTML based conditionals 
require_once(DIR '/includes/adminfunctions_template.php');
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

//First we need to query the table.
$sql $db->query_first("SELECT * FROM " TABLE_PREFIX "my_table WHERE column = 'X' ");


//Now we need to convert the HTML based conditionals to PHP based 
eval('$done = "' compile_template($sql['my_field']) . '" ;');

//Print the results to the screen
echo $done;

?>

I have tested the security and it returns dangerous code as plain text. This means that no one can do mischievous actions towards your forums.
================================================== ==============


All times are GMT. The time now is 07:12 AM.

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.01254 seconds
  • Memory Usage 1,731KB
  • 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
  • (4)bbcode_php_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