Archives page - need unique heading from date field

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

Re: [Deborah] Archives page - need unique heading from date field

By Chris - August 8, 2009

Hi Deborah,

Since you are passing the year and month in the query string to your archive list page, you can extract them from the query string:

<?php echo htmlspecialchars($_GET['date_month'])?>
<?php echo htmlspecialchars($_GET['date_year'])?>


Note that htmlspecialchars() is important for cross-site scripting security here.

Also note that the above code will fail if those two query string variables are not supplied. If your page is meant to be called without them sometimes, you'll need some "if" code in there to detect that case.

Hope this helps! Let us know how it's going. :)
All the best,
Chris

Re: [chris] Archives page - need unique heading from date field

By Deborah - August 8, 2009

Chris,

Thanks! That worked for me.

The date is therefore displayed as: 7 2009

Ideally, I'd like to see: July 2009, but I don't think that's possible. Unless you know of a way to do that, I'll be happy with the formatting as is.

I appreciate your help.
Deborah

Re: [Deborah] Archives page - need unique heading from date field

By Chris - August 9, 2009

Hi Deborah,

Practically anything is possible in PHP :)

<?php echo date("F", mktime(0, 0, 0, intval($_GET['date_month']), 10)) ?>
<?php echo htmlspecialchars($_GET['date_year'])?>


Please let us know if you have any more questions.
All the best,
Chris

Re: [chris] Archives page - need unique heading from date field

By Deborah - August 9, 2009

Chris,

You are brilliant! Thanks for that piece of code. It displays the month and year exactly as ordered!

Deborah