Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 04:28:07 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155543 Posts in 21714 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Losing functionality inside include(' ')  (Read 279 times)
ande159

Offline Offline

Posts: 7


« on: December 30, 2010, 06:02:18 PM »

I'm writing some PHP using the code section on one of my Wb pages and would like to include some code using the include(' '); statement.  However, when I do this, I lose functionality of the WB code.

For example, if I want to display "Hello <username>" using the WB code section, this works:
Code:
global $wb;
echo '<p>Hello: '.$wb->get_username().'</p>';

However, if within the WB code section I write
Code:
include('otherPphScript.php');
and within otherPhpScript.php I have
Code:
global $wb;
echo '<p>Hello: '.$wb->get_username().'</p>';
then I get no output whatsoever.

Anyone know what's going on?

Thanks.
Logged
PurpleEdge

Offline Offline

Posts: 232



WWW
« Reply #1 on: January 01, 2011, 04:28:18 AM »

You probably need to use the path to the included file so the page you are displaying it from can find it...

include(WB_PATH . '/mysubfolder/myscript.php');
Logged
ande159

Offline Offline

Posts: 7


« Reply #2 on: January 03, 2011, 04:37:05 PM »

No, that's not it. I have some other debug information that's getting displayed inside my included php file so I know it's running.

What must one do in order to access the $wb->get_username() function or the $_SESSION['USERNAME'] variable inside an included php file within a WB code section??
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2858



WWW
« Reply #3 on: January 03, 2011, 07:47:44 PM »

Since you include another file the global scope doesn't work!

You need to include the config.php and start the WB-class

Somthing like:
Code:
// Watch the path!!
require('../../config.php');

// Include the WB class
require_once(WB_PATH.'/framework/class.frontend.php');

// Create new frontend object
$wb = new frontend();

After this you'll have the wb variables and functions.

Good luck,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!