Showing pages in Who's Online outside of phpBB root

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

Ok, so the way my site is set up, I have ./ which is my site root. It runs on the phpBB engine just like any page inside the board root would. I then have ./board/ which is my site's root index the link points to the ./board/index.php page. What I am trying to do is make the Who's Online page show the page name when they are in that location. It current shows them as online, but they are shown to be on the Index page, rather then on the Home page.

In viewonline, I have tried the following:

Code: Select all

case '../index':
            $location = 'Home page';
            $location_url = append_sid("{$phpbb_root_path}../index.$phpEx");
        break; 
But it doesn't work because, as I have learned, the preg_match above is ignoring anything that has non-alpha-numeric characters at the start (I think).

So does anyone know of a way to make it recognize pages up one directory from the main phpBB root directory? Thanks for any help in advance.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

It's been six hours, so bump. :)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
comkidwizzer3
Registered User
Posts: 375
Joined: Fri Jul 13, 2007 8:24 am
Location: $user->data['user_location'];
Contact:

Re: Showing pages in Who's Online outside of phpBB root

Post by comkidwizzer3 »

:lol:

Hmm... House was trying to do with tools.php :roll: :P

Anyway, try deleting preg_match, simple enough :twisted:
~My MODs~
Login After Register - v1.0.0 | Custom Ranks MOD - RC

~!Hasher!~
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

Hadn't thought of just deleting the preg_match. I'll try it and let you know. 8-)

EDIT: Hmm didn't work. If you just simply delete the preg_match(), $on_page doesn't get set so the switch() breaks. So I tried some complicated stuff using strpos() and str_split() to get everything before the last period. That worked as I had hoped, except for people who were on viewforum or viewtopic. So now I've reverted back to how it was and am at square one. :/
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

I didn't reply right away because of the 6 hour rule. Unfortunately, that means that you missed my followup. Here's what I said:
EDIT: Hmm didn't work. If you just simply delete the preg_match(), $on_page doesn't get set so the switch() breaks. So I tried some complicated stuff using strpos() and str_split() to get everything before the last period. That worked as I had hoped, except for people who were on viewforum or viewtopic. So now I've reverted back to how it was and am at square one. :/
Does anyone know exactly what I need to do to achieve this?
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

I take it this isn't an easy thing to do, then? :S
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
Sam
Former Team Member
Posts: 2082
Joined: Thu Jan 22, 2009 3:59 am
Location: Sacramento, CA
Name: Sam Thompson
Contact:

Re: Showing pages in Who's Online outside of phpBB root

Post by Sam »

I have had to do something similar.

At the top of each page that belongs to your website and NOT phpBB, add this code:

Code: Select all

define('IN_WEBSITE', true);
$website_path = '/'; // meaning index.php in your site root      
This needs to go before $user->session_start() is called.

Now, open board/includes/session.php
FIND:

Code: Select all

            if (isset($_COOKIE[$config['cookie_name'] . '_sid']) || isset($_COOKIE[$config['cookie_name'] . '_u'])) 
ADD BEFORE:

Code: Select all

        if (defined('IN_WEBSITE'))
        {
            global $website_path;
            $this->page['page'] = $website_path;
        } 
Next, open board/viewonline.php

FIND

Code: Select all

                $location = $user->lang['INDEX'];
                $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); 
REPLACE WITH

Code: Select all

            if(defined('IN_WEBSITE'))
            {
                $location = 'Site Home';
                $location_url = append_sid("/");                
            }
            else
            {
                $location = $user->lang['INDEX'];
                $location_url = append_sid("{$phpbb_root_path}index.$phpEx");
            } 
Now, in that same switch, add your other cases. Like if you had a page where you had $website_path = '/blog/'; Add the following case:

Code: Select all

        case '/blog/':
            $location = 'Viewing Blog';
            $location_url = append_sid("/blog/");        
        break; 
Credit goes to evil<3 for figuring a lot of this out.
User avatar
DoYouSpeakWak
Registered User
Posts: 2310
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak
Contact:

Re: Showing pages in Who's Online outside of phpBB root

Post by DoYouSpeakWak »

This might be a bit offtopic. But it seems to be related and might inspire you.

http://www.phpbb3bbcodes.com/viewtopic.php?f=40&t=3195
http://www.phpbb3bbcodes.com/viewtopic.php?f=40&t=4013
Whatever you share comes back. Support the phpBB Communities
My Validated and Released Modifications
Offering paid services. 10+ years of experience with phpBB3 and as System Administrator.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Showing pages in Who's Online outside of phpBB root

Post by imkingdavid »

Thanks Syntax, I'll try that out as soon as I have the chance. And thanks for the links DYSW. :D
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Locked

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