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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2007, 02:24 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to evalute a $vbulletin->option variable in a phrase?

Anyone know how to make a vbulletin->option variable evaluate in a phrase? I'm trying to use the phrase as part of the description for an admincp setting.

For example, I have the variable $vbulletin->options['throttle_posts_time'] set to 24.

I want my phrase to read:
Quote:
Maximum number of posts in a 24 hour period? Set to -1 for an unlimited number of posts allowed.
I've tried:
Quote:
Maximum number of posts in a {{vbulletin->options['throttle_posts_time']}} hour period? Set to -1 for an unlimited number of posts allowed.
Quote:
Maximum number of posts in a {{$vbulletin->options['throttle_posts_time']}} hour period? Set to -1 for an unlimited number of posts allowed.
Quote:
Maximum number of posts in a $vbulletin->options['throttle_posts_time'] hour period? Set to -1 for an unlimited number of posts allowed.
with no luck. The variable still stays as the string (like {{vbulletin->options['throttle_posts_time']}}) instead of being evaluated. Any ideas?

Thanks!
Reply With Quote
  #2  
Old 04-11-2007, 03:11 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

EDIT: Sorry, didn't fully understand
Reply With Quote
  #3  
Old 04-11-2007, 03:15 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The phrase should be
Code:
Maximum number of posts in a {1} hour period? Set to -1 for an unlimited number of posts allowed.
Then, call the phrase using:
PHP Code:
construct_phrase($vbphrase['phrase_name'], $vbulletin->options['throttle_posts_time']); 
Reply With Quote
  #4  
Old 04-11-2007, 03:30 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by magnus View Post
Then, call the phrase using:
PHP Code:
construct_phrase($vbphrase['phrase_name'], $vbulletin->options['throttle_posts_time']); 
The problem is that the phrase is being displayed as part of the usergroup permissions using an xml file:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?php construct_phrase($vbphrase['throttle_posts_throttle'], $vbulletin->options['throttle_posts_time']);?>
<bitfields product="throttle_posts">
	<bitfielddefs>
		<group name="ugp">
			<group name="throttle_postspermissions">
				<bitfield name="throttle_postspermissions" intperm="true" group="throttle_postspermissions" phrase="throttle_posts_throttle">1</bitfield>
			</group>
		</group>
	</bitfielddefs>
</bitfields>
I don't see any way to evaluate the php statement. Even if I put it in the above code wrapped in php tags, it won't get evaluated since the web server only sees the file as an xml file.
Reply With Quote
  #5  
Old 04-11-2007, 03:36 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, since you're trying to evaluate a variable where no variable is expected you'll need to modify the backend.

In the calling PHP file, you'll need to perform an str_replace(); somewhere in the function call parsing the XML data. This will most likely require file edits, as I don't believe there are any appropriate hooks available.
Reply With Quote
  #6  
Old 04-11-2007, 03:38 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by magnus View Post
Well, since you're trying to evaluate a variable where no variable is expected you'll need to modify the backend.

In the calling PHP file, you'll need to perform an str_replace(); on the phrase before outputting.
k, thx. That's way too much work just to make it look pretty for admins! :-)
Reply With Quote
  #7  
Old 04-11-2007, 03:41 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea, I just checked. The changes to make would be in /includes/class_bitfield_builder.php -- and there are no hooks available. Alternatively, you could probably do it in /admincp/usergroup.php but, again, no hooks available.
Reply With Quote
  #8  
Old 04-12-2007, 10:48 AM
hambil's Avatar
hambil hambil is offline
 
Join Date: Jun 2004
Location: Seattle
Posts: 1,719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CyberRanger View Post
The problem is that the phrase is being displayed as part of the usergroup permissions using an xml file:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?php construct_phrase($vbphrase['throttle_posts_throttle'], $vbulletin->options['throttle_posts_time']);?>
<bitfields product="throttle_posts">
    <bitfielddefs>
        <group name="ugp">
            <group name="throttle_postspermissions">
                <bitfield name="throttle_postspermissions" intperm="true" group="throttle_postspermissions" phrase="throttle_posts_throttle">1</bitfield>
            </group>
        </group>
    </bitfielddefs>
</bitfields>
I don't see any way to evaluate the php statement. Even if I put it in the above code wrapped in php tags, it won't get evaluated since the web server only sees the file as an xml file.
Well, I haven't tried this, but because of the way vb processes templates you might be able to put code into a phrase. e.g. make the value of the actual phrase throttle_posts_throttle be
Code:
construct_phrase($vbphrase['throttle_posts_throttle'], $vbulletin->options['throttle_posts_time']);
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:35 PM.


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.03971 seconds
  • Memory Usage 2,239KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_code
  • (2)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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