php - phpbb navbar in external website -


i have phpbb3 integrated in site.

i have login in header webpage explained in https://wiki.phpbb.com/external_login.

all works fine, go bit further, have navbar in website header, see new messages , user profile in website header. using code:

    <?php define('in_phpbb', true); $phpbb_root_path = '../phpbb3/'; $phpex           = substr(strrchr(__file__, '.'), 1); include($phpbb_root_path . 'common.' . $phpex); // start session management $user->session_begin(); $auth->acl($user->data); $user->setup();  ?>     <div class="registro">  <?php 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         } ?>          </li>      </ul>      <?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     } ?>       </ul>       <span class="corners-bottom"><span></span></span></div>   </div>   <?php } else //user not logged in       {     include('logingeneral.php');     // login form } ?>         </div>    

i use custom login form if user not register, if user register show navbar modified.

that code works when in phpbb3 menu in site, mean when surfing within forum can show navbar in website header, when example in home page get

fatal error: using $this when not in object context in c:\wamp\www\esp\cabecera.php on line 2

i think file maybe load files , change $this->_rootref in whole code, bit lost.

edited: still stuck this, can me please? think have replace $this->_rootref $_rootref , add include don't know which. thanks

un poco tarde quizas, pero $this-> se refiere al objeto que esta declarado, por eso no te funciona fuera del contexto, en tu site donde no existe ese objeto (object oriented programming).

lo mas seguro es que se refiera al objeto forum, donde esta declarada la variable _rootref

lo mas facil seria ver qué objecto es $this en ese contexto y llamarlo directamente con php desde fuera, sin usar object oriented o averiguar quien declara la variable _rootref['s_user_logged_in'] y usar eso directamente.

puedes probar poniendo un echo $this-> _rootref en esa página para ver que se traduce y tratar de usarlo luego, si te dice que no existe, tendras que ver donde esta declarado _rootref['s_user_logged_in'] y trabajar con eso.

(english)

a bit late maybe, $this-> refering declared object in page using object oriented programming. object exists on context, not exist outsidte of in other non-phpbb pages you'll error, no matter what.

i haven't looked closely @ code it's referring forum object or whichever object holds _rootref variable.

the easiest thing find out object $this refers in context , try call outside pages. or find out _rootref['s_user_logged_in'] declared , use function in pages or variation of it.

you can try echoing out on page: echo $this->_rootref see if exists or echo $this->_rootref['s_user_logged_in'] if doesn't. other that, _rootref['s_user_logged_in'] in project see it's being declared.

hope helps someone.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -