Page 3 of 3

Re: Accessing php variables from outside phpBB instances

Posted: Wed Sep 12, 2007 7:49 am
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...

Re: Accessing php variables from outside phpBB instances

Posted: Wed Sep 12, 2007 12:14 pm
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'); 

Re: Accessing php variables from outside phpBB instances

Posted: Thu Sep 13, 2007 11:11 am
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?

Re: Accessing php variables from outside phpBB instances

Posted: Thu Sep 13, 2007 12:06 pm
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.

Re: Accessing php variables from outside phpBB instances

Posted: Thu Sep 13, 2007 3:27 pm
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.

Re: Accessing php variables from outside phpBB instances

Posted: Mon Jun 30, 2008 11:39 pm
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');
}

?>

Re: Accessing php variables from outside phpBB instances

Posted: Tue Jul 01, 2008 11:18 am
by Brf
$phpbb_root_path has to be a relative path, not an absolute one.

Re: Accessing php variables from outside phpBB instances

Posted: Tue Jul 01, 2008 1:20 pm
by drathbun
Also please note that your path is phpBB3 and this is the phpBB2 MOD Writers forum. :)

Re: Accessing php variables from outside phpBB instances

Posted: Wed Jul 02, 2008 3:48 pm
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