vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   use vb phrases in php file (https://vborg.vbsupport.ru/showthread.php?t=320171)

aminp30 09-09-2015 12:01 PM

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?

squidsk 09-09-2015 06:14 PM

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.

aminp30 09-09-2015 06:23 PM

Quote:

Originally Posted by squidsk (Post 2554670)
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.

cellarius 09-10-2015 05:38 AM

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

aminp30 09-10-2015 09:53 AM

Quote:

Originally Posted by cellarius (Post 2554713)
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

Zachery 09-11-2015 09:56 AM

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();



aminp30 09-11-2015 11:18 AM

Quote:

Originally Posted by Zachery (Post 2554842)
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?

kh99 09-11-2015 12:04 PM

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.

aminp30 09-11-2015 12:15 PM

Quote:

Originally Posted by kh99 (Post 2554851)
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

kh99 09-11-2015 12:18 PM

How did you call the second php page?


All times are GMT. The time now is 02:58 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.01092 seconds
  • Memory Usage 1,748KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete