Include static pages into the 'who is online' list

Started by DutchJam, January 14, 2011, 03:54:22 AM

Previous topic - Next topic

DutchJam

Pleasante greetings,

Im  created a few static pages around my forum.

Is there a way to include these pages into the 'who is online' list when people ware watching them?

Tnx!
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

Not without making them dynamic pages (SSI.php will help here), and having their presence be logged in to SMF's database, and then have the who's online code figure out that people are there.

It's not a simple, or small, job. You'd actually be quicker making them SMF pages which at least fall through the logging system, but that sort of depends on knowing what the pages were, how many, that sort of thing.

DutchJam

Tnx for the reply.

Actually, the static pages are part of the SMF (I think).

I used this http://www.simplemachines.org/community/index.php?topic=390247.msg2698239#msg2698239 to create them.

Does this help?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

Then they're dynamic, not static for a start.

But no, they're not part of SMF because they're not index.php?action=something pages, which means the user will not be logged as being on them (so the URL they're on is never stored, even if you explicitly ask to log the user's online presence)

DutchJam

Okay, understood.

But how do I convert them into SMF pages, without loosing any content?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

Well, since I have no idea what the code you've used is, I have no idea how to help you.

IceXaos

If you're on RC3, this could help.  ( I think RC4 is the same ... but haven't used it myself. )

http://www.simplemachines.org/community/index.php?topic=402675.0

Arantor

There are no changes in RC4 that would cause any problems.

DutchJam

Sorry...  :-[

I used this code for the pages:

<?php 
//Set the banning active
$ssi_ban true;

//Path to SSI.php
require(dirname(__FILE__) . '/SSI.php');

//Page title. This will appear in the browser
$context['page_title_html_safe'] = 'Custom Page';

//This is self explanatory
template_header(); 

//Here we define the link tree
$context['linktree'] = array(
  
'href' => $scripturl,
  );
  
//Here is the content, such as the title and the body message of the custom page.

echo'
         <span class="clear upperframe"><span></span></span>
         <div class="roundframe"><div class="innerframe">'
;
         echo
'
         <div class="cat_bar">
         <h3 class="catbg">Hello everyone</h3>
         </div>
          <p>This is a custom page example. pretty cool, huh.</p>'
;
         echo
'
         </div></div>
        <span class="lowerframe"><span></span></span>'
;   

//This is self explanatory too.        
template_footer(); 

?>


Can I add the code IceXaos mentoined into this one without rewriting the whole thing?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

It will be a rewrite to make it work exactly as intended, but it's a smaller rewrite than trying to mash up the Who's Online.

DutchJam

Thanks, that's not so hard.

Works already.

But I also use the SimpleAd mod. To use the ads in other pages I have to add this code to the pages:
//Loading ads
require_once('Subs-Ads.php');
   load_ads();


Then, on the place I want the ad to appear:

template_ad_position('_adname');


But the ad mod does not work on pages with the code IceXaos mentoined.

Any ideas?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

Please define "does not work" - does it not show the ads, does it give you an error, does it do something else?

DutchJam

Not showing ads, not showing an error...

The page looks as it looks without the code in it.
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor



DutchJam

-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Kays

Hi, can't help with the ads thing. But showing who's viewing that page in the who's online list is fairly simple.

Since that page isn't an "action", before SSI.php is included you need to define $_GET['action']. That would be something like this with this_page being the name of that page.

$_GET['action'] = 'this_page';


If you have a button or tab created for that page in Subs.php then change this_page to the name of that button. This will also get that button to highlight if you are on that page..

Then after SSI.php is included add the following:


writeLog();


Finally, add the following line to who.{language}.php.


$txt['whoall_this_page'] = 'Viewing this page.';


If the page is named differently or for additional pages replace the this_page with what that page is named.

$txt['whoall_this_page']

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Arantor

I've seen plenty of cases where that actually doesn't work properly, usually depending on how cookies are configured and in some cases what the session contained beforehand - which is why I didn't mention it. In fact the code in SSI is geared to being logged as being outside the forum specifically.

DutchJam

Thanks for all your replies guys!

All those codes make me a lil nervous (a glass of nice wine will solve that immediately), but I appreciate it.
Learning more about SMF every day, interesting stuff for a old guy like me...

So this is what I did so far:

I re-wrote the page with the code IceXaos mentioned at http://www.simplemachines.org/community/index.php?topic=402675.0

The page works fine with ../index.php?action=MyPage, without the ads so far.

Then I added this line to who.english.php in /Themes/Default/Languages:

$txt['whoall_Mypage'] = 'is viewing my page.';

Works perfect in my case, the page is listed in the 'who is online list' when somebody is viewing it. So that is solved too.

So, almost there, few questions to go.

The ads problem for example...
And is it possible to add sub-pages from MyPage (MyPage1, MyPage2, ect...) on the same way?
Is the pages listed in the stats now?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

QuoteIs the pages listed in the stats now?

Yes.

QuoteAnd is it possible to add sub-pages from MyPage (MyPage1, MyPage2, ect...) on the same way?

If they become action=MyPage2 or whatever, yes - it's completely extensible that way. It's only tricky if you get into extending it to be action=MyPage;subaction=Page2 or similar.

QuoteThe ads problem for example...

That's odd. What code are you using in the template now?

Advertisement: