Help - Search - Members - Calendar
Full Version: table columns code
Movable Type Community Forum > Additional Resources > Tips and Tricks
mutedgirl
What I'm trying to do is to use the columns code I use for my photo-blog to generate table cells (from here: http://www.scriptygoddess.com/archives/001342.php)and use it in a full archive page with calendars (from here: http://www.scriptygoddess.com/archives/001247.php)and I also am trying to combine it with this yearly archive idea from Brooke (http://www.brookelyn.org/dayspast/2003/Jan/02.php)

Here is the example page I'm working with:

http://muted.com/2002archives.php

This is the code I have in the template:


CODE
<!-- THIS SHOWS THE ACRHIVES IN MONTH FORMAT - JANUARY THRU DECEMBER. -->

<script language="javascript">
<!--
// number of columns
var numColmax = 4;

var numCol = 1;
var done=false;
//-->
</script>

<table border=1 cellspacing=0 cellpadding=10>
<MTArchiveList archive_type="Monthly">

<script language="javascript">
<!--
if (numCol == 1) {
document.write("<tr>");
}
//-->
</script>
<td>


<!-- THIS CHECKS THE YEAR OF THE ENTRIES AND ONLY DISPLAYS THOSE FROM THE YEAR SPECIFIED. -->
<?php if (<$MTArchiveDate format="%Y"$> == '2002') : ?>

<!-- CHANGE THE OUTPUT OF THE LISTING AS DESIRED. JUST REMEMBER TO KEEP IT WITHIN THE PHP TAGS. -->


<$MTArchiveDate format="%B, %Y"$>
<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="0">
<TR>
<TD class="calhead">S</TD>
<TD class="calhead">M</TD>
<TD class="calhead">T</TD>
<TD class="calhead">W</TD>
<TD class="calhead">T</TD>
<TD class="calhead">F</TD>
<TD class="calhead">S</TD>
</TR>
<MTCalendar month="this">
<MTCalendarWeekHeader>
<TR>
<? $counter = 0; ?>
</MTCalendarWeekHeader>
<TD class="calbody" style="<MTCalendarIfToday>background-color: #999999;</MTCalendarIfToday>" BGCOLOR="<? echo $counter++ % 2 ? '#ffffff' : '#cccccc' ?>">
<MTCalendarIfEntries>
<MTEntries lastn="1"><a href="<$MTEntryLink archive_type="Daily"$>"><$MTCalendarDay$></A></MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank><BR></MTCalendarIfBlank>
</td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>

</td>



<script language="javascript">
<!--
numCol++
done = false

if (numCol > numColmax) {
document.write("</tr>");
numCol=1;
done = true;
}
//-->
</script>

<!-- ARCHIVE LIST ENDS -->

<?php endif; ?>
</MTArchiveList>


<script language="javascript">
<!--
if (!(done)) {
for (i=0; numCol <= numColmax; i++ )
{
document.write("<td>.</td>")
numCol++
}
}
if ((numCol >= numColmax) && !(done)) {
document.write("</tr>")
}
//-->
</script>




</table>


Everything seems to be working, except I'm getting two weird table cells all the way on the right (the one's with '.' inside of them, just so I could see what was happening).  I can't figure out what in the table code is making them appear.  Because everything else is working great- the calendars are lined up right and everything (and I can change the column variables and everything changes accordingly)  Any help??  Thanks!
mutedgirl
wow, the 2nd thing I figured out for myself today smile.gif  yay!

Here's what I changed- I moved:

CODE
<script language="javascript">
<!--
if (numCol == 1) {
document.write("<tr>");
}
//-->
</script>
<td>


to right before:
CODE
<$MTArchiveDate format="%B, %Y"$>


So the whole thing looks like this:
CODE
<!-- THIS SHOWS THE ACRHIVES IN MONTH FORMAT - JANUARY THRU DECEMBER. -->

<script language="javascript">
<!--
// number of columns
var numColmax = 4;

var numCol = 1;
var done=false;
//-->
</script>

<table border=1 cellspacing=0 cellpadding=10>
<MTArchiveList archive_type="Monthly">




<!-- THIS CHECKS THE YEAR OF THE ENTRIES AND ONLY DISPLAYS THOSE FROM THE YEAR SPECIFIED. -->
<?php if (<$MTArchiveDate format="%Y"$> == '2002') : ?>

<!-- CHANGE THE OUTPUT OF THE LISTING AS DESIRED. JUST REMEMBER TO KEEP IT WITHIN THE PHP TAGS. -->

<script language="javascript">
<!--
if (numCol == 1) {
document.write("<tr>");
}
//-->
</script>
<td>
<$MTArchiveDate format="%B, %Y"$>
<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="0">
<TR>
<TD class="calhead">S</TD>
<TD class="calhead">M</TD>
<TD class="calhead">T</TD>
<TD class="calhead">W</TD>
<TD class="calhead">T</TD>
<TD class="calhead">F</TD>
<TD class="calhead">S</TD>
</TR>
<MTCalendar month="this">
<MTCalendarWeekHeader>
<TR>
<? $counter = 0; ?>
</MTCalendarWeekHeader>
<TD class="calbody" style="<MTCalendarIfToday>background-color: #999999;</MTCalendarIfToday>" BGCOLOR="<? echo $counter++ % 2 ? '#ffffff' : '#cccccc' ?>">
<MTCalendarIfEntries>
<MTEntries lastn="1"><a href="<$MTEntryLink archive_type="Daily"$>"><$MTCalendarDay$></A></MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank><BR></MTCalendarIfBlank>
</td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>

</td>



<script language="javascript">
<!--
numCol++
done = false

if (numCol > numColmax) {
document.write("</tr>");
numCol=1;
done = true;
}
//-->
</script>

<!-- ARCHIVE LIST ENDS -->

<?php endif; ?>
</MTArchiveList>


<script language="javascript">
<!--
if (!(done)) {
for (i=0; numCol <= numColmax; i++ )
{
document.write("<td>.</td>")
numCol++
}
}
if ((numCol >= numColmax) && !(done)) {
document.write("</tr>")
}
//-->
</script>

</table>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.