Blog Archive

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 13, 2012   (RSS)

Re: [shannonr] Blog Archive

By gregThomas - November 12, 2012

Hi Shannon,

It looks as if you have everything set up correctly on your date filter links, you just need to set allowSearch to true in your getRecords function and it should work.

Code
<?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."); }

//If date_year isn't set, set it to 2012
if(!@$_REQUEST['date_year']){
$_REQUEST['date_year'] = '2012';
}


list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => true,
'orderBy' => 'createdDate DESC',
));
?>


I've also added an if statment (highlighted in blue) that will check if the date_year has been set in the url and added to the request array and if it hasn't, will change it to 2012.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Blog Archive

By shannonr - November 12, 2012

Hi Greg - thanks for your reply. Unfortunately I'm not getting any filtering at all - all the posts are showing up regardless of of which year is selected...any ideas? I had createdDate before and I've now changed it to date, still no joy...

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$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."); }
if(!@$_REQUEST['date_year']){
$_REQUEST['date_year'] = '2012';
}

// load records from 'blog'
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'loadUploads' => true,
'allowSearch' => true,
'orderBy' => 'date DESC',
));
?>

<?php
// get list of unique months and years with articles ----
$query = "SELECT DATE_FORMAT(date, '%Y') as Year, YEAR(date) as year FROM cms_blog GROUP BY Year ORDER BY date";
$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 ?>

Re: [shannonr] Blog Archive

By gregThomas - November 13, 2012

Hi,

I've done some testing and I can't work out why it's not filtering anything at all, for example:

http://www.space-alchemy.com/2012/blog.php?num=5463557

should stop the page returning anything.

Please could you fill out a second level support request for me?


https://www.interactivetools.com/support/email_support_form.php


Then I can take a closer look at what could be causing the issue.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com