News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Include static pages into the 'who is online' list

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

Previous topic - Next topic

DutchJam

Quote from: Arantor on January 23, 2011, 02:48:24 PM
Yes.

Loud 'n clear  :)

Quote from: Arantor on January 23, 2011, 02:48:24 PM
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.

Well, to be honest, I would love to have MyPage2 (and 3 and 4 and...) really as a sub-page of MyPage, so yes, I'm interested in the tricky part... If I'm not too boring...

Quote from: Arantor on January 23, 2011, 02:48:24 PM
QuoteThe ads problem for example...
That's odd. What code are you using in the template now?

The same as above, I did not changed it yet. I worked perfect in the 'old' custom page and for now, I really dunno why it does not in the code I use now...


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

Arantor

QuoteWell, to be honest, I would love to have MyPage2 (and 3 and 4 and...) really as a sub-page of MyPage, so yes, I'm interested in the tricky part... If I'm not too boring...

You can *present* it as a sub-page without it actually *being* a sub page which will save you the headache of adding support to specific subpages in the Who code.

QuoteThe same as above, I did not changed it yet. I worked perfect in the 'old' custom page and for now, I really dunno why it does not in the code I use now...

Which is, exactly?

DutchJam

Quote from: Arantor on January 23, 2011, 06:08:07 PM
You can *present* it as a sub-page without it actually *being* a sub page which will save you the headache of adding support to specific subpages in the Who code.

Sounds interesting, but how do I do that?

Quote from: Arantor on January 23, 2011, 06:08:07 PM
Which is, exactly?

I use the SimpleAds mod (http://custom.simplemachines.org/mods/index.php?mod=2557). Works perfect, easy to use.

When I create my own pages, I have to add this code manually somewhere on top in the source code of that page:

//Loading ads
require_once($sourcedir . '/Subs-Ads.php');
   load_ads();


Then I have to add a line like this on the place where I want the ad appears:

template_ad_position('_nameposition');

It works fine with the custom pages I did so far. With use this code:

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

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

//Loading ads
require_once($sourcedir '/Subs-Ads.php');
   
load_ads();

//Page title. This will appear in the browser
$context['page_title_html_safe'] = 'JamaicaForum.nl - Shop Muziek';

//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.
....


But using the code above, the page is not a ../index.php?action=blabla thing and the page is not listed in Who is Online, stats and so.

So now I use the code IceXaos mentioned:

<?php

if (!defined('SMF'))
die(
'Hacking attempt...');

function 
MyPage() {
    global 
$context;
    
$context['page_title'] = 'My Page Title Goes Here';

    function 
template_main() {
        echo 
'<center><b>Content goes here.  Remember to echo all HTML as this is in PHP.</b></center>';
    }
    
}


And I thought by adding the 'loading ads code' described above the ads appear. But no, I tried by adding the 'loading ads code' on several places in the source, but it does not work...

The page itself works fine and is listed in Who is ect. Only the ads do not appear.

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

Arantor

QuoteSounds interesting, but how do I do that?

Quite easily. You just build the code as you have done already but you just present the page and its HTML as if it were sub pages. Just because pages look like they're subpages doesn't mean they actually have to be...

As for ads, try this.

<?php

if (!defined('SMF'))
die(
'Hacking attempt...');

function 
MyPage() {
    global 
$context$sourcedir;

    require_once(
$sourcedir '/Subs-Ads.php');
    
load_ads();

    
$context['page_title'] = 'My Page Title Goes Here';

    function 
template_main() {
        
template_ad_position('_nameposition');
        echo 
'<center><b>Content goes here.  Remember to echo all HTML as this is in PHP.</b></center>';
    }
    
}


The key point is that the ads are loaded in the 'source' side and displayed in the template.

DutchJam

Quote from: Arantor on January 24, 2011, 06:28:45 AM
Quite easily. You just build the code as you have done already but you just present the page and its HTML as if it were sub pages. Just because pages look like they're subpages doesn't mean they actually have to be...

Hmmmm, but how do I call them if I want the page to be a subpage from .../index.php?action=mainpage ?

And the ads: nope, still no ads. Page loads fine, but not any ad around.

I was thinking... Is it possible the ads code is not working because the page is stored in the 'Sources' directory?

With the 'old' code for the custom page I could run the page from the site root. But with the new code (which I need for the Who is part) I have to run the file from the 'Sources' dir. Could be the cause of the problem?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Arantor

QuoteHmmmm, but how do I call them if I want the page to be a subpage from .../index.php?action=mainpage ?

You still make them as index.php?action=mainpage2 or action=mainpage3. You just make the *content* look like it's a subpage.

QuoteIs it possible the ads code is not working because the page is stored in the 'Sources' directory?

I shouldn't think so, seeing how the rest of SMF is stored in the same way...

QuoteCould be the cause of the problem?

Again, I shouldn't think so but I never looked at it before, the one time I put ads on a site, I just added the code manually to the templates rather than using an ad manager.

DutchJam

Quote from: Arantor on January 24, 2011, 10:43:05 AM
You still make them as index.php?action=mainpage2 or action=mainpage3. You just make the *content* look like it's a subpage.

Got it. Already worked it out, it's the most easy option I think...

Quote from: Arantor on January 24, 2011, 10:43:05 AM
Again, I shouldn't think so but I never looked at it before, the one time I put ads on a site, I just added the code manually to the templates rather than using an ad manager.

I think your right about this. After all, I'm talking here about a page of 6 to 10. Not so hard to add some code manually :)

Anyway, thanks for all your help so far, I learn a lot like this!
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Advertisement: