Welcome to Geeklog Tuesday, November 12 2019 @ 05:57 am EST

Geeklog Forums

Static Page on every topic


Status: offline

James Fryer

Forum User
Junior
Registered: 06/08/02
Posts: 17

I have updated my hack to work with GL 1.3.7.

This hack enables a static page to be displayed at the head of any topic page, by giving the static page the same title as the topic id.

I have not tested this code very much. Any fixes/improvements are welcome.

I think this is a very useful feature, and it would be nice to see it in the GL code, if only so that I don't have to reintegrate it with every upgrade! It will require some way to disable it so that sites with existing static pages named the same as topics don't break.

The code below entirely replaces the existing code in index.php, from the first line of the block comment to the 'if ($shownews) {'.

PHP Formatted Code

/*
 *  Staticpage on Frontpage Addon (Hacked together by MLimburg)
 *
 *  If a staticpage with the title 'frontpage' exists, then it is shown before
 *  the news messages.  If this staticpage has the label 'nonews', then it is
 *  shown INSTEAD of news messages.
 *  Added by James Fryer, if the staticpage title is the same as the topic id,
 *  the page will be displayed before the messages in that topic.
 */


$shownews = true;

// Get the title of the static page to use
if (empty ($topic))
{
    $staticpage_title = 'frontpage';
}
else {
    $staticpage_title = $topic;
}

// check if static pages plugin is installed and enabled
if (DB_getItem ($_TABLES['plugins'], 'pi_enabled', "pi_name = 'staticpages'") == 1) {
   
    $spsql = "SELECT sp_content,sp_label,sp_format FROM {$_TABLES['staticpage']} WHERE sp_title = '$staticpage_title'";
    $spresult = DB_fetchArray (DB_query ($spsql));

    if ($spresult['sp_label'] == 'nonews') { // replace news entirely
        $shownews = false;
        switch ($spresult['sp_format']) {
            case 'noblocks':
                $display .= COM_siteHeader ('none');
                break;
            case 'allblocks':
            case 'leftblocks':
                $display .= COM_siteHeader ('menu');
                break;
        }

        $display .= stripslashes ($spresult['sp_content']);

        if ($spresult['sp_format'] == 'allblocks') {
            $display .= COM_siteFooter (true);
        } else if ($spresult['sp_format'] != 'blankpage') {
            $display .= COM_siteFooter ();
        }
    } else { // display static page content before the news
        $display .= COM_siteHeader();
        if (($_SP_CONF['in_block'] == 1) && !empty ($spresult['sp_label'])) {
            $display .= COM_startBlock ($spresult['sp_label']);
        }
        $display .= stripslashes ($spresult['sp_content']);
        if (($_SP_CONF['in_block'] == 1) && !empty ($spresult['sp_label'])) {
            $display .= COM_endBlock ();
        }
    }
} else {
    $display .= COM_siteHeader();
}


if ($shownews) {

Status: offline

geKow

Forum User
Full Member
Registered: 12/01/03
Posts: 445
Hey, thats quite exactly what I was looking for and untill now, it seems to work quite good. Thank you :-)

Anonymous

Anonymous
Can we see this demo'd somewhere? I'm not sure I follow what it does.

Status: offline

James Fryer

Forum User
Junior
Registered: 06/08/02
Posts: 17
OK, take a look at http://www.richard-durrant.com/index.php?topic=airport . Note that there is a block of explanatory text at the top of the topic, this is in a static page named 'airport' (the same as the topic). In a nutshell, that's what my code lets you do. Note that this site uses the older version (haven't had time to upgrade yet) but the principle is the same.

Status: offline

schmaxelander

Forum User
Newbie
Registered: 24/09/02
Posts: 10
This is great - thank you!

Got an addition, so that anonymous users can see another static page (titled 'anonymous_frontpage') on the front, when no topic is set:
PHP Formatted Code
// Get the title of the static page to use
if (empty ($topic)) {
    // AS - 13.03.03 - Addon: special static page for anonymous
    // Anonymous user get a special frontpage
    if ( empty($_USER['uid']) ) {
        $staticpage_title = 'anonymous_frontpage';
    } else {
        $staticpage_title = 'frontpage';
    }
} else {
You could extend this so that anonymous users may get a special page in every topic. But have not yet found out how to include more than one static pages on top.
Was inspired by another hack by jlhughes.

~ Alex

volkoff

Anonymous
Nice idea, would love to try, any directions where exactly it should be inserted?

Anonymous

Anonymous
Nevermind, I red it one more time and got about index.php, sorry

Anonymous

Anonymous
This one is great! I looked for exactly this solution, Thanks a lot Smile

Anonymous

Anonymous
I'm getting this error
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/adrian/www/index.php on line 90
This is my line 90
$spsql = "SELECT sp_content,sp_label,sp_format FROM ($_TABLES['staticpage']} WHERE sp_title = '$staticpage_title'";
This is really something I'd like to use, can anyone offer any advice?

Status: offline

keystone

Forum User
Chatty
Registered: 21/09/02
Posts: 50
Works great, Thanks!

Status: offline

Rado1

Forum User
Newbie
Registered: 03/03/03
Posts: 8
Location:Europe/Prague
I used this hack on my 1.3.7 version. But just now I have upgraded to 1.3.9 and I'm disappointed that it is not in the oficial tar-ball.

index.php of the 1.3.9 is a little bit different and it is hardly to find the propper place to insert this hack to it.

May I ask you to publish this hack for 1.3.9?
[If you have it]

Thanks,
--
Rado1

Status: offline

samstone

Forum User
Full Member
Registered: 29/09/02
Posts: 820
Rado1

This is already part of the StaticPages features.

You can set your static page as the center page and can put it either at the top, after feature story, or bottom of any topic.

Hope this helps!

Sam

All times are EST. The time is now 05:57 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content