Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 11-04-2005, 07:29 PM
TyleR's Avatar
TyleR TyleR is offline
 
Join Date: Nov 2004
Location: North Carolina
Posts: 349
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 11-04-2005, 08:33 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Reply With Quote
  #4  
Old 11-05-2005, 02:59 AM
TyleR's Avatar
TyleR TyleR is offline
 
Join Date: Nov 2004
Location: North Carolina
Posts: 349
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm...weird..because mine worked and yours didnt for me on both my 3.5.0 and a private 3.0.10
Reply With Quote
  #5  
Old 11-07-2005, 02:47 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:44 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.03574 seconds
  • Memory Usage 2,216KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete