|
Post by stryker on Aug 7, 2007 8:09:56 GMT -5
Hi
Is it by design that {{calendar}} in an archive template shows last month?{{header}} <div class="content"> <h1>This Month</h1> {{calendar}} <h1>Log Archives</h1> <p>{{logarchivelist}}</p> </div>
<div class="content"> <h1>Entries</h1> <p>{{logentrylist}}</p> </div>
{{footer}} This archive page presently shows July rather than August as I was expecting.
(v1.7.3)
Thanks Geoff
|
|
|
Post by Carlos Phelps on Aug 7, 2007 8:33:20 GMT -5
|
|
|
Post by stryker on Aug 7, 2007 17:46:06 GMT -5
Thanks for looking into that Carlos. It certainly proves it does what I've seen, whether or not by design Your suggestion to use {{calendar [mm]/[yy]}} interests me a great deal since in one of my archives I'd like to if possible show calendars for current month and the two previous months adjacent. How were you thinking of supplying the template with the values for current month and current year? And is it possible to do maths on these values somehow to show previous months relative to that? Cheers! Geoff
|
|
|
Post by stryker on Aug 19, 2007 8:57:37 GMT -5
Hi again,
Since I couldn't see template variables for past month values I thought I'd take a crack at some javascript to do the job in the archive template...however have hit a snag. One which is quite obvious now looking back.
Firstly, here's the javascript as a proof of concept:
<SCRIPT language="JavaScript"><!--
todaysdate = new Date(); month = todaysdate.getMonth() + 1; year = todaysdate.getYear();
for (x=0;x<=2;x++) // adjust loop to suit desired number of past years to display // starting loop at 0 displays current year first { pastmonth = month-x; pastyear = year; if (pastmonth < 1) { pastmonth = pastmonth + 12; pastyear--; }
pastmonth = (pastmonth>9)?pastmonth:'0'+pastmonth; // zero pad month if required pastyear += ''; // convert year to string pastyear = pastyear.substr(1); // take last two characters only
// output text to template page document.write("{{calendar "+pastmonth+"/"+pastyear+"}}"); }
//--></SCRIPT>
It does the job, and outputs exactly what I need, however the result is rather than the template variables being interpreted so calendars are output, they come out as text. Of course!
{{calendar 08/07}}
{{calendar 07/07}}
{{calendar 06/07}}
So all I've actually proven it's getting late and I shouldn't code tired ;D
Is there a way to generate part of the template in javascript? Or an easier approach I've missed?
Thanks Geoff
|
|
|
Post by coldstone on Aug 21, 2007 17:24:05 GMT -5
I am confused as to what you are trying todo? You want to show the last three months calendars?
|
|
|
Post by stryker on Aug 23, 2007 9:21:04 GMT -5
I am confused as to what you are trying todo? You want to show the last three months calendars? Hi coldstone, Yes that's my intention. I've been distracted from the task for a few days now.
|
|
|
Post by coldstone on Aug 23, 2007 17:36:55 GMT -5
Yeah, that seems reasonable, but tricky. You would need the templates to evaluate to something before Gm worked on them.
I think this can only be done with a code change. I can make a note for a future enhancement. Otherwise, I think you would have to manually change the template every month and change the number, then rebuild. Seems like you want a {{calendar}} var that you could pass an off set into.
|
|