|
Now I could build the table that was for each of the columns that held four entries. <$mt:Var name="colpos" value="0"$> <mt:Entries> <$mt:Var name="colpos" op="++" setvar="colpos"$> The above created the variable colpos, and initialized it to 0. Then I went into the loop for all the entries. This loop is in context. If you are making a yearly archive it will loop through all the entries from newest to oldest. If you are building a monthly archive page, it will loop though the post entries for that given month. That next line increments the colpos variable from 0 to 1. It took several hours to remind myself how Movable Type does an increment of a variable. Without the setvar part, it would just output the colpos plus one, without changing hte variable itself. Sigh, Perl. <mt:If name="colpos" eq="1"> <table class="content-table cat-page" ><tbody><tr><td class="content"> <mt:If name="__first__"> <h1><$mt:ArchiveTitle$> posts</h1> <mt:Else> <h1><$mt:ArchiveTitle$> posts (con't)</h1> </mt:If> </mt:If> These lines test colpos if its a "1" and if so, outputs the HTML for the top of the table that makes a column. Inside that test is anther test for if the "1" post is the very first post, ie, the most recent. That gets a heading of the year or month, and the word "posts". If colpos is a 1 but it's not the very first, the <mt"Else> changes the header text to "posts (con't)". So the first column of 2014 is "2014 posts" and the remaining columns get the header "2014 posts (con't)". |
|
Next comes the contents of the column with four posts listed. <div class="four-col"> <img src="<$mt:BlogURL$>horz-bar.gif" class="horz-bar" alt="horizontal bar"> <$mt:Include module="Entry Summary Yearly"$> </div> I give the div a class to style the size and appearance of the posts. I put in a horizontal bar to separate the posts form one another. I used a subtle gradient grey in a gif file. Then I call the module "Entry Summary Yearly" that puts a thumbnail picture and the deck, called excerpt text, and makes them the link to the post URL. <mt:If name="colpos" eq="4"> <$mt:Var name="colpos" value="0"$> </td> <td><img src="<$mt:BlogURL$>sidebar.gif" class="vert-bar" /></td> </tr> <tr> <td class="pointer-cell"><img src="<$mt:BlogURL$>flow-pointers.gif" class="flow-pointers" alt="move up a little to the right" /> <img src="<$mt:BlogURL$>flow-pointers-end.gif" class="flow-pointers-r" alt="This is the end." /></td> <td class="post-pointer-cell"></td> </tr></tbody></table> <mt:Else> Now I test for the colpos being a "4", or the last post in any column table. If so, I reset colpos to 0, where it will be incremented to a "1" right as the next loop starts. Then I output the HTML for the bottom of the column table. I used tables to display the posts so the web page is responsive. On a wide screen it will display 3 or 4 columns. On a phone it displays just one. The columns are floated left in the CSS. |
|
Next I have to test if the post is the last post, since the last column does not have to have 4 posts in it. So the <mt:Else> is saying colpos was not a 4, but then I test to see if it was the last post. <mt:If name="__last__"> </td> <td><img src="<$mt:BlogURL$>sidebar.gif" class="vert-bar" /></td> </tr> <tr> <td class="pointer-cell"><img src="<$mt:BlogURL$>flow-pointers.gif" class="flow-pointers" alt="move up a little to the right" /> <img src="<$mt:BlogURL$>flow-pointers-end.gif" class="flow-pointers-r" alt="This is the end." /></td> <td class="post-pointer-cell"></td> </tr></tbody></table> </mt:If> </mt:If> If the entry post is the last post, then I do the exact same HTML closing of the table as if it was the fourth post at the bottom of the column. Then I close the "last" test with </mt:If> and then I close the test for the 4th post with </mt:If>. Then I close the entries loop with the last line: </mt:Entries> Movable Type is rare in that it is software that tries to be context-aware. So when you publish an entry, it next will go and make all the archives, in my case the monthly posts, and yearly posts. Archives could also be author or date or dozens of other things. What is nice is when the program is making a page of the years posts, the <mt:Entries> loop will return all the posts for that year. If the program is building a monthly archive page, the <mt:Entries> loop will only cycle through the posts for that particular month. |
|
This post is in these categories: | |