Welcome to Geeklog, Anonymous Sunday, September 01 2024 @ 12:01 am EDT
Geeklog Forums
Featured article only on top page
I was wondering how difficult it would be to have just the featured article show on the top page. Not so difficult, it turned out. In index.php, replace the following code:
if ($newstories) {
$sql .= "AND (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) ";
}
// new from here
if (($_CONF['featured_only'] == 1) && !($page == 1)) {
$offset = 1 + (($page - 2) * $limit);
} else {
$offset = ($page - 1) * $limit;
}
$sql .= "ORDER BY featured DESC, date DESC";
$result = DB_query ("SELECT *,UNIX_TIMESTAMP(date) AS day " . $sql
. " LIMIT $offset, $limit");
$nrows = DB_numRows ($result);
$data = DB_query ("SELECT COUNT(*) AS count " . $sql);
$D = DB_fetchArray ($data);
if ($_CONF['featured_only'] == 1) {
$num_pages = 1 + (ceil (($D['count']-1) / $limit));
} else {
$num_pages = ceil ($D['count'] / $limit);
}
if ($nrows > 0) {
for ($x = 1; $x <= $nrows; $x++) {
$A = DB_fetchArray($result);
if ($A['featured'] == 1) {
$feature = 'true';
} elseif (($x == 1) && ($_CONF['showfirstasfeatured'] == 1)) {
$feature = 'true';
$A['featured'] = 1;
}
$display .= COM_article($A,'y');
if ($A['featured'] == 1) {
$display .= PLG_showCenterblock (2, $page, $topic);
}
if ($_CONF['featured_only'] == 1 && $feature) {
break;
}
}
// new up to here
$display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
and add the variable
$_CONF['featured_only'] = 1; // set to 1 to show only the featured article on the top page when a featured article exists
to your config.php, and bob's your uncle. The team might want to check this in case I'm missing something really stupid.
Seems to work for me here.
Cheers,
Euan.
-- Heather Engineering
-- No job too small
Text Formatted Code
if ($newstories) {
$sql .= "AND (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) ";
}
// new from here
if (($_CONF['featured_only'] == 1) && !($page == 1)) {
$offset = 1 + (($page - 2) * $limit);
} else {
$offset = ($page - 1) * $limit;
}
$sql .= "ORDER BY featured DESC, date DESC";
$result = DB_query ("SELECT *,UNIX_TIMESTAMP(date) AS day " . $sql
. " LIMIT $offset, $limit");
$nrows = DB_numRows ($result);
$data = DB_query ("SELECT COUNT(*) AS count " . $sql);
$D = DB_fetchArray ($data);
if ($_CONF['featured_only'] == 1) {
$num_pages = 1 + (ceil (($D['count']-1) / $limit));
} else {
$num_pages = ceil ($D['count'] / $limit);
}
if ($nrows > 0) {
for ($x = 1; $x <= $nrows; $x++) {
$A = DB_fetchArray($result);
if ($A['featured'] == 1) {
$feature = 'true';
} elseif (($x == 1) && ($_CONF['showfirstasfeatured'] == 1)) {
$feature = 'true';
$A['featured'] = 1;
}
$display .= COM_article($A,'y');
if ($A['featured'] == 1) {
$display .= PLG_showCenterblock (2, $page, $topic);
}
if ($_CONF['featured_only'] == 1 && $feature) {
break;
}
}
// new up to here
$display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
and add the variable
Text Formatted Code
$_CONF['featured_only'] = 1; // set to 1 to show only the featured article on the top page when a featured article exists
to your config.php, and bob's your uncle. The team might want to check this in case I'm missing something really stupid.
Seems to work for me here.
Cheers,
Euan.
-- Heather Engineering
-- No job too small
6
5
Quote
All times are EDT. The time is now 12:01 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