View Full Version : use vb phrases in php file
aminp30
09-09-2015, 12:01 PM
hi,
I added a page to my vb and used a php file in it. and now I need use vb phrases such as
<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
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:
$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
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:
if($bbuserinfo['userid'])
{
// This user is a member
DoSomething();
}
else
{
// this user is not a member
DoSomethingElse();
}
aminp30
09-11-2015, 11:18 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:
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?
You would need to include the vbulletin global.php in your custom script for that to work. The vbulletin scripts do this:
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
You would need to include the vbulletin global.php in your custom script for that to work. The vbulletin scripts do this:
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
How did you call the second php page?
aminp30
09-11-2015, 12:41 PM
How did you call the second php page?
I created a plugin with this code:
ob_start();
require_once('question.php');
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('quiz',array('php_include ' => $php_include));
and in my template I added this code:
{vb:raw php_include}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.