Accessing php variables from outside phpBB instances

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 »

Yes I created the variable in page_header.php, then I call it from a php file called /wiki/index.php. In this file I have also put in:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = '../';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
I also added the line

Code: Select all

include($phpbb_root_path . 'includes/page_header_custom.'.$phpEx);
This simply didn't work, and it still just tries to find an image at /wiki/{IMAGE_PRIVMSG}, it obviously isn't recognising the variable. I think I'll just give up on this one for a while until I get my head around the incredibly frustrating mediawiki structure. phpBB is programmed so well, it's easy to forget how hard it can be to recognise the strcuture of a different program...
Image
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53379
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf »

You still didnt answer my question...

You said you created the variable in page_header.php...
Like this?

Code: Select all

$template->assign_vars(array (
	'IMAGE_PRIVMSG' => 'myimage.gif
));
Therefore, you must include page_header.php, not page_header_custom.php.

Then, where did you put your /wiki/{IMAGE_PRIVMSG} ?
Is it in a TPL file which you invoke with:

Code: Select all

$template->set_filenames(array( 
        'body' => 'mywiki.tpl'
        ));
$template->pparse('body'); 
User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 »

sorry I meant to write page_header.php not page_header_custom. Yes the variable is created the way you described, it's created in page_header.php like all the others, and it works because I have it functioning at http://bottleweb.org/forum.php, the /wiki/{IMAGE_PRIVMSG} link is done from a file called bottleweb.php, which is the skin file containing the header information.

Is this what could be creating the problem? I can't call {IMAGE_PRIVMSG} from index.php because it doesn't contain any actual page layout data, it's all in bottleweb.php. Any ideas?
Image
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53379
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf »

Brf wrote:Then, where did you put your /wiki/{IMAGE_PRIVMSG} ?
Is it in a TPL file which you invoke with:

Code: Select all

$template->set_filenames(array( 
        'body' => 'mywiki.tpl'
        ));
$template->pparse('body'); 
Template tags, of course, must be parsed from a TPL file with the $template object. How else would your {tag} be replaced with the text? If you are simply echoing the template tag, there is nothing to replace it.
User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 »

oh ok thank you! I sort of dived in the deep end here, that makes a lot of sense now!

Thanks a lot for your help, I appreciate it.
Image
TinaMay
Registered User
Posts: 11
Joined: Thu Jun 26, 2008 4:14 pm

Re: Accessing php variables from outside phpBB instances

Post by TinaMay »

I have been trying to do the same thing but with no success. Basically, I am trying to access the S_USER_LOGGED_IN variable so that I can customize the links on my menu bar based on whether or not someone is logged into the message board. As background, I have the message board embedded within my main webpage using an iframe. I have posted the below code into the very top of one of my web pages and it isn't displaying any data. The page is just a plan .html page. Does it need to be a php? Any thoughts on why this isn't working???


<?php
define('IN_PHPBB', true);
$phpbb_root_path = 'http://s244682566.onlinehome.us/ExDelicti/phpBB3';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if($userdata['session_logged_in'])
{
echo('Hi ' . $userdata['username'] . '!');
}
else
{
echo('You are a guest');
}

?>
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53379
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf »

$phpbb_root_path has to be a relative path, not an absolute one.
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Re: Accessing php variables from outside phpBB instances

Post by drathbun »

Also please note that your path is phpBB3 and this is the phpBB2 MOD Writers forum. :)
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Lumpy Burgertushie »

and , yes , that page has to have a .php extension if you expect the php in it to work.

and also, it is doubtful that any of this will work if you are putting phpbb in a iframe.

you should be adding your header and footer code for the rest of your site, to the overall_header.tpl and overall_footer.tpl files of your phpbb style.

robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
Post Reply

Return to “[2.0.x] MOD Writers Discussion”