Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-09-2015, 12:01 PM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default use vb phrases in php file

hi,

I added a page to my vb and used a php file in it. and now I need use vb phrases such as
Code:
<vb:if condition="$show['member']">
how can I use them in my custom php page?
Reply With Quote
  #2  
Old 09-09-2015, 06:14 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't those types of code are used exclusively in templates. You can use templates that have that code in them in your php files, but that code, since it isn't php can't be used directly in your php files.
Reply With Quote
  #3  
Old 09-09-2015, 06:23 PM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
You can't those types of code are used exclusively in templates. You can use templates that have that code in them in your php files, but that code, since it isn't php can't be used directly in your php files.
thank you for reply. i know . that was an example to show you what I need.
this code works in php file:
Code:
$vbulletin->userinfo['username']
I need some code like this one. and I need a code to set data to database too.
Reply With Quote
  #4  
Old 09-10-2015, 05:38 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why would you need a phrase in the php file? All output should be done in the template, so that's where a phrase would typically be called.

Regarding database manipulation:
https://vborg.vbsupport.ru/showthread.php?t=119350
Reply With Quote
Благодарность от:
aminp30
  #5  
Old 09-10-2015, 09:53 AM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cellarius View Post
Why would you need a phrase in the php file? All output should be done in the template, so that's where a phrase would typically be called.

Regarding database manipulation:
https://vborg.vbsupport.ru/showthread.php?t=119350
thanks for reply dear cellarius. your link was great

I have an excel forum. I need to know my user grade in excel. so I decided to create some questions and let them to solve and use their score in postbit.

I created a php page. I need access database to use random from questions and I need modify database to change the custom field that I want show in postbit
Reply With Quote
  #6  
Old 09-11-2015, 09:56 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know why anyone didn't tell you, the code you linked is:

1. Not a phrase
2. template code, and specifically a vbulletin defined variable.

$show['member'] checks to see if a user has a valid userid. Assuming you've included the vBulletin global.php to get you into the vBulletin environment, the same can be done in php:

PHP Code:
if($bbuserinfo['userid'])
{
// This user is a member
    
DoSomething();
}
else
{
// this user is not a member
    
DoSomethingElse();

Reply With Quote
Благодарность от:
aminp30
  #7  
Old 09-11-2015, 11:18 AM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
I don't know why anyone didn't tell you, the code you linked is:

1. Not a phrase
2. template code, and specifically a vbulletin defined variable.

$show['member'] checks to see if a user has a valid userid. Assuming you've included the vBulletin global.php to get you into the vBulletin environment, the same can be done in php:

PHP Code:
if($bbuserinfo['userid'])
{
// This user is a member
    
DoSomething();
}
else
{
// this user is not a member
    
DoSomethingElse();


thank you so much but your code doesn't worked.would you please give me an example?
and also in else part, I need system message page that says you don't have permissions.

is that possible?
Reply With Quote
  #8  
Old 09-11-2015, 12:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would need to include the vbulletin global.php in your custom script for that to work. The vbulletin scripts do this:
PHP Code:
require_once('./global.php'); 
Your custom script would need to be in the vbulletin 'root' directory (the same one as forum.php, showthread.php, etc). If it isn't, then you'd need to cwd() to the vbulletin root before including global.php (then cwd back to the original directory if needed).

You can call the vbulletin function print_no_permission() to get the standard no permission message.
Reply With Quote
  #9  
Old 09-11-2015, 12:15 PM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You would need to include the vbulletin global.php in your custom script for that to work. The vbulletin scripts do this:
PHP Code:
require_once('./global.php'); 
Your custom script would need to be in the vbulletin 'root' directory (the same one as forum.php, showthread.php, etc). If it isn't, then you'd need to cwd() to the vbulletin root before including global.php (then cwd back to the original directory if needed).

You can call the vbulletin function print_no_permission() to get the standard no permission message.
thank you dear k99

I created a php page with tutorial in this page
https://vborg.vbsupport.ru/showthread.php?t=228112

in this tutorial we use require_once('./global.php');
is that OK or we need it directly in my php codes?
as you know I created a php page and in template I called another php page. I need this codes for second php page
Reply With Quote
  #10  
Old 09-11-2015, 12:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How did you call the second php page?
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:41 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04745 seconds
  • Memory Usage 2,266KB
  • 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
  • (2)bbcode_code
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete