Hi
Sorry if this had been done (to death no doubt), I couldn't quite get there from searching this forum.
Anyway, I need to have my blog page showing only this years' posts (i.e. all posts from 2012), and then showing a list on the right of posts archived by year.
I have got the list to appear (using suggestion by Deborah on this forum), but its loading all posts - I need to figure out how to filter them to only show that year's content (also when the page first loads it needs to just be this current year's posts).
Here is the code on the page: (simplified version of http://www.space-alchemy.com/2012/blog.php)
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/spaceal/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($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => false,
'orderBy' => 'createdDate DESC',
));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<title>Space Alchemy</title>
</head>
<body>
<div id="leftColText">
<h2>Blog</h2>
<?php foreach ($blogRecords as $record): ?>
Title: <?php echo htmlencode($record['title']) ?><br/>
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
Content: <?php echo htmlencode($record['content']) ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<?php foreach ($record['uploads'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>
Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>
Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Caption) : <?php echo htmlencode($upload['info2']) ?><br/><br/>
<hr/>
<?php endforeach ?>
<?php endforeach ?>
</div>
<!----------------------------- archive list ----------->
<div id="rightColText">
<h2>Blog Menu</h2>
<?php
$query = "SELECT DATE_FORMAT(date, '%Y') as Year, YEAR(date) as year FROM cms_blog GROUP BY Year ORDER BY createdDate";
$result = mysql_query($query) or die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n");
while ($record = mysql_fetch_assoc($result)):
?>
<a href="blog.php?date_year=<?php echo $record['year'] ?>"><?php echo $record['Year']; ?></a><br/>
<?php endwhile ?>
</div>
</body>
Any help here much appreciated!
Shannon