The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I want to parse conditions with a custom databasetable, so according to vb.com I need to use the compile_template() function.
Code:
/** * Processes a raw template for conditionals, phrases etc into PHP code for eval() * * @param string Template * * @return string */ function compile_template($template, &$errors = array()) |
#2
|
||||
|
||||
![]()
I do on vb 4.
|
#3
|
|||
|
|||
![]()
I've looked through some mods here on vb.org. Is it true you can only parse specific specified condition codes and not the template where you want to parse every possible code?
|
#4
|
|||
|
|||
![]()
I'm not sure what you're asking. There is a set of php functions that you are allowed to use in an if condtion, if that's what you mean. Are you saying you want to compile a template without that restriction?
|
#5
|
|||
|
|||
![]()
Yes. I have made a simple cms -for outside the forum directory- with some custom tables, but the content in those custom tables can't use conditions and other php functions (the codes show up unparsed in the HTML output). According to vb.com I need to use the compile_template() function for this to work and I'm having trouble to get this function working.
Database content: PHP Code:
PHP Code:
|
#6
|
|||
|
|||
![]()
I did this short test by creating a plugin using hook misc_start:
Code:
if ($_REQUEST['do'] == 'compile') { require_once("includes/adminfunctions_template.php"); $template = '<if condition="$show[member]">Not viewable for guests</if>'; echo compile_template($template); exit; } and the result is: Code:
".(($show[member]) ? ("Not viewable for guests") : (""))." so it seems like it's working, although I'm not sure how you're supposed to deal with the dots at the beginning and end, I guess when the function is used there are other strings added to the beginning and end. Anyway, are you using the return value of compile_template()? I don't think it changes the parameter you pass. |
#7
|
|||
|
|||
![]()
Yes. I also tried echoing and evaling the db->query or the template name.
But seeing your short test, it's not possible to process the custom db as a vBulletin template? If not, I might be able to wrap it up with some custom templates. |
#8
|
|||
|
|||
![]()
Sorry, I don't really understand what you are asking.
But in case it helps, I played with it a little more and got this: Code:
if ($_REQUEST['do'] == 'compile') { require_once("includes/adminfunctions_template.php"); $show[member] = true; $template = '<if condition="$show[member]">Not viewable for guests</if>'; eval ('$output = "' . compile_template($template) . '";'); echo $output; exit; } and the output is Code:
Not viewable for guests but maybe this has nothing to do with your problem. |
#9
|
||||
|
||||
![]()
Take a look at this mod. Bob uses compile_template for search and replace.
https://vborg.vbsupport.ru/misc.php?...mcategoryicons |
#10
|
|||
|
|||
![]()
Thanks, I will look in it
Quote:
PHP Code:
HTML Code:
Not viewable for guestsNot viewable for members |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|