View Single Post
  #1  
Old 11-04-2005, 04:16 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01156 seconds
  • Memory Usage 1,793KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete