vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Evaluating a conditional from a variable in the template (https://vborg.vbsupport.ru/showthread.php?t=100076)

CyberRanger 11-04-2005 04:16 PM

Evaluating a conditional from a variable in the template
 
I have a variable called $pagetext that contains this information:

Code:

<if condition="is_member_of($bbuserinfo, 9)">Member of Group</if>More words ...
I want to have that variable evaluated by a template
Code:

eval('$html .= "' . fetch_template('pagetext') . '";');
and eventually output by another template
Code:

eval('print_output("' . fetch_template('shell') . '");');
When I try to do that, the conditional is simply ignored, ie even if the user is not a member of group 9, the "Member of Group" text still appears.

Any ideas on how to do this?

************************************************** ***

Okay, here's a nasty solution I found. First, let me explain the situation better. I have a custom table in the forums db that holds text to be output on a custom webpage. I process that page through vbulletin to use vb's styles, permissions, etc. In my example above, the variable $pagedata, holds the content for the page. It also contains vb conditionals. If I just evaluate the variable in a template, the template was simply ignoring the conditionals.

So .... here is my ugly solution. When the information for that page is updated in my custom table, I create a template for that page.
PHP Code:

    $db->query("DELETE FROM `" TABLE_PREFIX "template` WHERE `title` LIKE '$pageurl'");
    
$db->query("INSERT INTO `" TABLE_PREFIX "template` (`styleid`,`title`,`template`,`template_un`,`templatetype`,`dateline`,`username`,`version`) VALUES (1, '".$pageurl."','".mysql_real_escape_string(compile_template($pagedata))."','".mysql_real_escape_string($pagedata)."','template',".TIMENOW.",'Brent Layman','3.5.0')"); 

then I rebuild my templates:
PHP Code:

    require_once(DIR '/includes/adminfunctions.php'); 
      
build_all_styles(); 

Now, when I want to display the page, I first call the template and evaluate the bbcode:
PHP Code:

    eval('$pagedata = "' fetch_template($pageurl) . '";');
    
    
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list()); 
    
$parsed_text $parser->do_parse($pagedata11111$cachable); 
    
$pagedata $parsed_text

and now evaluate into my original template:
PHP Code:

eval('$html .= "' fetch_template('pagetext') . '";'); 

There's gotta be a better way!! :o

TyleR 11-04-2005 07:29 PM

Well, first off, you didnt define what the member is of in the conditional.. it should be this:

Code:

<if condition="is_member_of($bbuserinfo[usergroupid], 9)">Member of Group</if>More words ...
as for the other stuff, I dont have a clue..not in tune with vB's 3.5.x API.

CyberRanger 11-04-2005 08:33 PM

Quote:

Originally Posted by TyleR
Well, first off, you didnt define what the member is of in the conditional.. it should be this:

Code:

<if condition="is_member_of($bbuserinfo[usergroupid], 9)">Member of Group</if>More words ...

Weird ... I'd say you are absolutely correct but oddly my conditional does work like that!? Maybe it defaults to usergroupid??

Edit - if you check out the bottom of this page (http://www.vbulletin.com/docs/html/m...n_conditionals) that is the correct usage to search both the primary and secondary groups. :surprised:

TyleR 11-05-2005 02:59 AM

hmm...weird..because mine worked and yours didnt for me on both my 3.5.0 and a private 3.0.10

CyberRanger 11-07-2005 02:47 PM

Quote:

Originally Posted by TyleR
hmm...weird..because mine worked and yours didnt for me on both my 3.5.0 and a private 3.0.10

Yeah, that is weird. But, that was just an example. Anyone know how to do what I originally requested? (besides the create a template example I showed above?)

To restate the question:

I'm pulling text from a database table. The text contains template conditional code. All of the text is placed in a variable.

That variable is then called in a template. When the template is evaluated, the conditional is being ignored. Any ideas on how to make the conditional work in this situation?


All times are GMT. The time now is 05:27 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.01080 seconds
  • Memory Usage 1,739KB
  • 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
  • (5)bbcode_code_printable
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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