Welcome to Geeklog, Anonymous Monday, November 25 2024 @ 02:57 pm EST
Geeklog Forums
Static Page on every topic
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) {
Anonymous
James Fryer
schmaxelander
Got an addition, so that anonymous users can see another static page (titled 'anonymous_frontpage') on the front, when no topic is set:
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 {
Was inspired by another hack by jlhughes.
~ Alex
volkoff
Anonymous
Anonymous
Anonymous
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?
Rado1
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
- 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