Archives

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 24, 2009   (RSS)

By design9 - August 21, 2009

Hello,
I wanted to know what might the best way to build an archives page that will list articles for a specific month. I have a multi section and on the list page, I will have a thumbnail of that month's magazine cover, title w/ link to details page and month/year. See example: http://www.carolinaparent.com/test/archives.php

On the details page I want to have the larger image, month/year, title and a list of articles for only that month/year. See example:
http://www.carolinaparent.com/test/archivesdetails.php

The problem I am having is trying to figure out the best way to get the articles (that I will tag for the specific month) to only show up on that page. I can get all the articles to show but I cannot figure out how to only display the articles for that month once you click to go to the details page.
Another website that has a great example of what I am trying to accomplish is this page: http://www.dallaschild.com/pastissues.asp

Any help that can guide me in the right direction is greatly appreciated!
Thanks!
April

Re: [apdance9] Archives

By Chris - August 21, 2009

Hi apdance,

Let's assume that you have two sections, named Issues and Articles. Both sections have a date/time field called "date", and for aesthetics, have the Specify Time option disabled.

On your Issue detail page, you'd want to pull the year and month out of the selected Issue record and use that information in a WHERE clause to find only Articles which match the year and month, like so:

list($issuesRecords, $issuesMetaData) = getRecords(array(
'tableName' => 'issues',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$issuesRecord = @$issuesRecords[0]; // get first record

// get year and month from selected Issue
$year = date('Y', strtotime( $issuesRecord['date'] ) );
$month = date('n', strtotime( $issuesRecord['date'] ) );

// search for articles matching that year and month
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => "YEAR(date)={$year} AND MONTH(date)=${month}",
));


I've attached a complete Issue details page for reference.

Hope this helps! :D
All the best,
Chris
Attachments:

issuesdetail.php 3K

Re: [chris] Archives

By design9 - August 24, 2009

Hi Chris,

That worked perfectly! Thank you so much!

The last I need to do with this is have a current issue page that will display the current issue cover, title and links of articles for that month. Is there anyway to program this so it can automatically change each month (as each month changes) or would I need to manually change it. I was thinking I could set-up a checkbox that says "current month" and use a php if statement but then the user would have to go back each month and uncheck the expired month. Trying to figure out an easier way to accomplish this... I know I am missing something. Any suggestions would be appreciated!

Thanks!

April