Plugins : MTGrid 2.0 Jan 28 2003 | # | C:34

MTGrid 2.0 Implemented in Dynamic Templates

January 28, 2003 - updated February 19, 2006 (Download)

The MTGrid tags enable you to easily constuct tabular pages out of entry or category listings.

The following example lest all entries in a three column table:

<table>
   <MTGrid num_columns="3">
      <MTEntries>
         <MTGridCell>
            <MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
            <td>
               <a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br/>
               <$MTEntryExcerpt$>
            </td>
            <MTGridIfRightColumn></tr></MTGridIfRightColumn>
         </MTGridCell>
      </MTEntries>
      <MTGridTrailingCells>
         <MTGridIfLeftColumn></tr></MTGridIfLeftColumn>
         <td>&nbsp;</td>
         <MTGridIfRightColumn></tr></MTGridIfRightColumn>
      </MTGridTrailingCells>
   </MTGrid>
</table>

Example: This grid index displays all entries - row by row - in a table of three columns.

Example: This transposed grid displays all entries - column by column - in a table of three columns.

Example: This colored grid index displays all entries in a table with alternatingly colored rows.

Example: This multi-page grid index displays all entries in a two-column table across multiple pages.


  • MTGrid
    The MTGrid tags should enclose one or more MTCell tags and specifies how the cells are rendered. The tag can be modified with the following attributes:
    • num_columns="n"
      Specifies how many columns there are in the grid. The default values is 5 columns.
    • num_rows="m"
      Specifies how many rows there are in the grid. The num_rows attribute overrides the num_column attribute.
    • transpose="1"
      Specifies that cells should be listed by column by column instead of row by row. The default is to list cells row by row.
    • right_to_left="1"
      Specifies that cells should be listed from right to left instead of from left to right. The default is to list cells from left to right.
    • enum_rows="n1,n2,…"
      A coma-separate list of values that can be accessed via the MTGridRowEnum tag. The default value is "0,1". For example, if you want to list entries in a table of red and green rows, you would use the following code:
      <table>
      <MTGrid enum_rows="red,green">
      <MTEntries>
      <MTCell>
         <MTGridIfLeftColumn><tr bgcolor="<$MTGridRowEnum$>"></MTGridIfLeftColumn>
         <td>...</td>
      ...
    • enum_columns="m1,m2,…"
      A coma-separate list of values that can be accessed via the MTGridcolumnEnum tag. The default value is "0,1". For example, if you want to list entries in a table of red and green columns, you would use the following code:
      <table>
      <MTGrid enum_rows="red,green">
      <MTEntries>
      <MTCell>
         <MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
         <td bgcolor="<$MTGridRowEnum$>">...</td>
      ...
  • MTGridCell
    Container tag the describes the content of a cell in the grid. Inside the cell you can use the following tags:
    • MTGridIfLeftColumn
      Conditional tag that is true in the left-most cells in the grid. You can use it to generate text at the beginning of each row:
      <MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
      ...
    • MTGridIfRightColumn
      Conditional tag that is true in the righ-most cells in the grid. You can use it to generate text at the end of each row:
      ...
      <MTGridIfRightColumn></tr></MTGridIfRightColumn>
    • MTGridIfTopRow
      Conditional tag that is true in the top cells in the grid.
    • MTGridIfBottomRow
      Conditional tag that is true in the bottom cells in the grid
    • MTGridCellNumber
      Displays the sequential number of the current cell (starting with 1).
    • MTGridRowNumber
      Displays the row number of the current cell.
    • MTGridColumnNumber
      Displays the column number of the current cell.
    • MTGridRowEnum
      Displays the enum value of the current row. The enum values are specified with the enum_rows attribute.
    • MTGridColumnEnum
      Displays the enum value of the current column. The enum values are specified with the enum_columns attribute.
  • MTGridTrailingCells
    Container that represents the leftover cells used to fill the grid. This tag generats 0 to num_columns-1 cells and may contain any of the tags that are valid inside the MTGridCell tag. Usually you’ll use this tag to fill the last row of a table with empty cells:
       ...
       <MTGridTrailingCells>
          <MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
          <td>&nbsp;</td>
          <MTGridIfRightColumn></tr></MTGridIfRightColumn>
       </MTGridTrailingCells>
    </MTGrid>
    
Version History
  • Version 2.0 - Feb 19 2006
    Rewrote for MT 3.2 - added support for dynamic templates.
  • Version 1.1.1 - June 18 2003
    Fixed MT version being changed.
  • Version 1.1 - May 27 2003
    Added right_to_left attribute.
    Fixed bug where MTEntryIfExtended, MTEntryIfAllowComments, etc. were always treated as being set.
  • Version 1.0 - Jan 28 2003
    Initial release.