Display Multi List titles but not current one
3 posts by 3 authors in: Forums > CMS Builder
Last Post: August 20, 2010 (RSS)
By (Deleted User) - August 20, 2010
Hello,
I have a news multi list page. On the detail page I have the following:
The page is displayed as normal. In the sidebar I would like to list all the Other news items but NOT the current one as obviously the visitor is on it.
In the sidebar I have the following:
How do I change the sidebar code to show all the latest news items other than the current one?
Thanks Jono
I have a news multi list page. On the detail page I have the following:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/finishs/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($news_pagesRecords, $news_pagesMetaData) = getRecords(array(
'tableName' => 'news_pages',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',));
list($onews_pagesRecords, $onews_pagesMetaData) = getRecords(array(
'tableName' => 'news_pages',));
$news_pagesRecord = @$news_pagesRecords[0];
if (!$news_pagesRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;}?>
The page is displayed as normal. In the sidebar I would like to list all the Other news items but NOT the current one as obviously the visitor is on it.
In the sidebar I have the following:
<ul class="latestnews">
<?php foreach ($onews_pagesRecords as $record): ?>
<li>
<img src="<?php echo $record['sidebar_list_url'] ?>" alt="<?php echo $record['list_title'] ?>" class="alignleft imgbox"/>
<span class="blogtitle"><a href="/news/<?php echo $record['url_keywords'] ?>-<?php echo $record['num'] ?>"><?php echo $record['list_title'] ?></a></span>
<p><?php echo $record['list_content'] ?></p>
</li>
<?php endforeach ?>
</ul>
How do I change the sidebar code to show all the latest news items other than the current one?
Thanks Jono
Re: [jonoc73] Display Multi List titles but not current one
By Chris - August 20, 2010 - edited: August 20, 2010
Hi Jono,
If you're not using $onews_pagesRecords for anything other than the sidebar, it would be easy enough to add a WHERE filter to not return the main detail page record. To do this, you'll need to move your code around a little so that your "Record not found" check runs before you try to use $news_pagesRecord['num'] for the WHERE. New code in red:
I hope this helps! Please let me know if you have any questions.
If you're not using $onews_pagesRecords for anything other than the sidebar, it would be easy enough to add a WHERE filter to not return the main detail page record. To do this, you'll need to move your code around a little so that your "Record not found" check runs before you try to use $news_pagesRecord['num'] for the WHERE. New code in red:
list($news_pagesRecords, $news_pagesMetaData) = getRecords(array(
'tableName' => 'news_pages',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$news_pagesRecord = @$news_pagesRecords[0];
if (!$news_pagesRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
list($onews_pagesRecords, $onews_pagesMetaData) = getRecords(array(
'tableName' => 'news_pages',
'where' => mysql_escapef('num <> ?', $news_pagesRecord['num']),
));
I hope this helps! Please let me know if you have any questions.
All the best,
Chris
Chris
Re: [chris] Display Multi List titles but not current one
By Perchpole - August 20, 2010
Chris -
Excellent! Another useful set-up.
You're cooking on gas today!
:0)
Perch
Excellent! Another useful set-up.
You're cooking on gas today!
:0)
Perch