Page 1 of 1

navbar in external website

Posted: Sun May 19, 2013 10:46 am
by chusito
Hello, I have phpbb3 integrated in my site.

I have the login in my header webpage like is explained in

All works fine, but I would like to go a bit further, I would like to have the navbar in my website header, then I could see new messages and user profile in my website header.
I am using this code

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = '../phpbb3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management

<div class="registro">

 if ($this->_rootref['S_USER_LOGGED_IN']) { ?>

<div class="navbar" style="background-image:url('../img/opaco.png');">
			<div class="inner"><span class="corners-top"><span></span></span>


			<?php if (! $this->_rootref['S_IS_BOT'] && $this->_rootref['S_USER_LOGGED_IN']) {  ?>

			<ul class="linklist leftside">
				<li class="icon-ucp">
					<a href="<?php echo (isset($this->_rootref['U_PROFILE'])) ? $this->_rootref['U_PROFILE'] : ''; ?>" title="<?php echo ((isset($this->_rootref['L_PROFILE'])) ? $this->_rootref['L_PROFILE'] : ((isset($user->lang['PROFILE'])) ? $user->lang['PROFILE'] : '{ PROFILE }')); ?>" accesskey="e"><?php echo ((isset($this->_rootref['L_PROFILE'])) ? $this->_rootref['L_PROFILE'] : ((isset($user->lang['PROFILE'])) ? $user->lang['PROFILE'] : '{ PROFILE }')); ?></a>
						<?php if ($this->_rootref['S_DISPLAY_PM']) {  ?> (<a href="<?php echo (isset($this->_rootref['U_PRIVATEMSGS'])) ? $this->_rootref['U_PRIVATEMSGS'] : ''; ?>"><?php echo (isset($this->_rootref['PRIVATE_MESSAGE_INFO'])) ? $this->_rootref['PRIVATE_MESSAGE_INFO'] : ''; ?></a>)<?php } if ($this->_rootref['S_DISPLAY_SEARCH']) {  ?> &bull;
					<?php } ?>

			<?php } ?>

			<ul class="linklist rightside">
				<?php if (! $this->_rootref['S_IS_BOT']) {  if ($this->_rootref['S_DISPLAY_MEMBERLIST']) {  ?><?php } if (! $this->_rootref['S_USER_LOGGED_IN'] && $this->_rootref['S_REGISTER_ENABLED'] && ! ( $this->_rootref['S_SHOW_COPPA'] || $this->_rootref['S_REGISTRATION'] )) {  ?><li class="icon-register"><a href="<?php echo (isset($this->_rootref['U_REGISTER'])) ? $this->_rootref['U_REGISTER'] : ''; ?>"><?php echo ((isset($this->_rootref['L_REGISTER'])) ? $this->_rootref['L_REGISTER'] : ((isset($user->lang['REGISTER'])) ? $user->lang['REGISTER'] : '{ REGISTER }')); ?></a></li><?php } ?>

					<li class="icon-logout"><a href="<?php echo (isset($this->_rootref['U_LOGIN_LOGOUT'])) ? $this->_rootref['U_LOGIN_LOGOUT'] : ''; ?>" title="<?php echo ((isset($this->_rootref['L_LOGIN_LOGOUT'])) ? $this->_rootref['L_LOGIN_LOGOUT'] : ((isset($user->lang['LOGIN_LOGOUT'])) ? $user->lang['LOGIN_LOGOUT'] : '{ LOGIN_LOGOUT }')); ?>" accesskey="x"><?php echo ((isset($this->_rootref['L_LOGIN_LOGOUT'])) ? $this->_rootref['L_LOGIN_LOGOUT'] : ((isset($user->lang['LOGIN_LOGOUT'])) ? $user->lang['LOGIN_LOGOUT'] : '{ LOGIN_LOGOUT }')); ?></a></li>
				<?php } ?>


			<span class="corners-bottom"><span></span></span></div>

<?php } else
     //user is not logged in  
    // this is a login form
 } ?>		
I use a custom login form if the user is not register, but if the user is register I show the navbar with some modified.

That code works when I am in the phpbb3 menu in my site, I mean when I am surfing within the forum I can show the navbar in my website header, but when I am for example in my home page I get

Fatal error: Using $this when not in object context in C:\wamp\www\esp\cabecera.php on line 2

I think the file maybe load some files and change $this->_rootref in the whole code, but I am a bit lost :?

Thank you very much

Re: navbar in external website

Posted: Wed May 29, 2013 9:33 pm
by chusito

I am here again hoping that someone could help me :cry:

I think I must change this->_rootref by $_rootref and mabye missing some includes :|


Re: navbar in external website

Posted: Thu May 30, 2013 10:10 pm
by DionDesigns
chusito wrote:I think I must change this->_rootref by $_rootref and mabye missing some includes :|
No, you must stop trying to use code from the template cache. ;)

You should either be setting up and using your own template file (by far the best option), or alternately, use the variables created by phpBB to output the appropriate information.

I know there are examples/tutorials here for creating external should take a look at them. Or if you insist on using PHP as in the code you posted, take a look at includes/functions.php and use the code which represents the template variables you are attempting to re-create.

Re: navbar in external website

Posted: Fri May 31, 2013 7:50 pm
by chusito
Hi DionDesigns,

Thank you very much for show me the way, I will read carefully functions.php. What I usually do is modify prosilver template, I have a custom version of overralheader.php. And I think I have viewed all the tutorial about integration here. I have the forum merged nice with the website, the only thing I would like to improve is to show the user profile and messages in the whole website, not only in the forum screen.

Thank you very much,


Re: navbar in external website

Posted: Thu Jun 25, 2015 4:27 pm
by s28400
I am trying to do the same thing, did you ever figure this out?