Posted on: 03/10/03 06:11am
By: James Fryer
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) {
'.
/*
* 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) {
Posted on: 03/10/03 05:00pm
By: geKow
Posted on: 03/10/03 08:19pm
By: Anonymous (Anonymous)
Posted on: 03/11/03 04:05am
By: James Fryer
Posted on: 03/13/03 08:44am
By: schmaxelander
// 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.
Posted on: 04/12/03 10:21pm
By: Anonymous (volkoff)
Posted on: 04/13/03 04:39am
By: Anonymous (Anonymous)
Posted on: 05/17/03 05:21pm
By: Anonymous (Anonymous)
Posted on: 05/20/03 03:18am
By: Anonymous (Anonymous)
$spsql = "SELECT sp_content,sp_label,sp_format FROM ($_TABLES['staticpage']} WHERE sp_title = '$staticpage_title'";
Posted on: 06/22/03 09:47am
By: keystone
Posted on: 04/25/04 07:04pm
By: Rado1
Posted on: 04/25/04 07:43pm
By: samstone