2009-09-04 8 views
0

Je travaille avec MT pour la première fois et j'ai rencontré un petit problème avec l'affichage d'une liste d'archives mensuelles. Je voudrais afficher une table où chaque année contenant des entrées est une ligne, et tous mois sont montrés comme des cellules dans chaque rangée. Les mois contenant des entrées sont affichés avec leurs noms enveloppés dans un lien vers l'archive mensuelle correspondante.Movable Type: Voir tous les mois dans ArchiveList, mettre en surbrillance actif

Le code HTML Je cherche serait quelque chose comme:

<table> 
<tr> 
<th>2009</th> 
<td><a href="link_to_jan_2009_archive">J</a></td> 
<td>F</td> 
<td>M</td> 
<td><a href="link_to_apr_2009_archive">A</a></td> 
<td>M</td> 
<td>J</td> 
<td>J</td> 
<td><a href="link_to_aug_2009_archive">A</a></td> 
<td>S</td> 
<td>O</td> 
<td>N</td> 
<td>D</td> 
</tr> 
<tr> 
<th>2008</th> 
    ... 
</tr> 
</table> 

Au moment où je reçois:

<table> 
<tr> 
<th>2009</th> 
<td><a href="link_to_jan_2009_archive">J</a></td> 
<td><a href="link_to_apr_2009_archive">A</a></td> 
<td><a href="link_to_aug_2009_archive">A</a></td> 
</tr> 
<tr> 
<th>2008</th> 
    ... 
</tr> 
</table> 

est ici le code MT en question:

<mt:ArchiveList type="Yearly" sort_order="descend"> 
<mt:ArchiveListHeader><table></mt:ArchiveListHeader> 
    <tr> 
     <th><$mt:ArchiveDate format="%Y"$></th> 
     <mt:ArchiveList type="Monthly" sort_order="ascend"> 
     <td><$mt:ArchiveDate format="%b"$></td> 
     </mt:ArchiveList> 
    </tr> 
    <mt:ArchiveListFooter> 
</table> 
</mt:ArchiveListFooter> 
</mt:ArchiveList> 

Le code que j'ai jusqu'à présent ne produit que des mois contenant des entrées pour chaque année. Quelqu'un pourrait-il m'aider à ajouter les autres mois?

Merci à l'avance,

Ross

+0

difficile, je n'ai aucune idée. Mais je pourrais vous aider à écrire un plugin si vous n'obtenez pas de réponse après quelques jours. –

+0

Merci! Je pourrais très bien vous parler de ça ... –

+0

OK. Maintenant il est tard donc c'est mieux si tu me le rappelles, comme demain. Vous pouvez écrire à oscherler @ [le domaine dans mon profil]. –

Répondre

0

L'archive que vous voulez est très similaire à une archive que j'ai écrit sur le Adventures in Movable Type.

Voici une version modifiée pour votre cas d'utilisation. Vous devrez faire une petite suppression pour obtenir les noms des mois raccourcis à la lettre unique que vous voulez.

Placez ce code dans un modèle d'index et publier:

<mt:SetHashVar name="month_map"> 
    <$mt:Var name="1" value="Jan"$> 
    <$mt:Var name="2" value="Feb"$> 
    <$mt:Var name="3" value="Mar"$> 
    <$mt:Var name="4" value="Apr"$> 
    <$mt:Var name="5" value="May"$> 
    <$mt:Var name="6" value="Jun"$> 
    <$mt:Var name="7" value="Jul"$> 
    <$mt:Var name="8" value="Aug"$> 
    <$mt:Var name="9" value="Sep"$> 
    <$mt:Var name="10" value="Oct"$> 
    <$mt:Var name="11" value="Nov"$> 
    <$mt:Var name="12" value="Dec"$> 
</mt:SetHashVar> 

<table> 
<mt:ArchiveList type="Yearly" sort_order="ascend"> 
    <mt:ArchiveListHeader><tr><$mt:ArchiveDate format="%Y" setvar="startYear"$></mt:ArchiveListHeader> 
    <$mt:ArchiveDate format="%Y" setvar="archiveYear"$> 
    <$mt:SetVar name="is_posts_year_{$archiveYear}" value="1"$> 
    <mt:ArchiveList type="Monthly"> 
     <$mt:ArchiveDate format="%m%Y" setvar="monthYear"$> 
     <mt:SetVarBlock name="links_{$monthYear}"><a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%b"$></a></mt:SetVarBlock> 
    </mt:ArchiveList> 
    <mt:ArchiveListFooter></tr><$mt:ArchiveDate format="%Y" setvar="endYear"$></mt:ArchiveListFooter> 
</mt:ArchiveList> 
<mt:For var="year" from="$startYear" to="$endYear"> 
    <mt:If name="is_posts_year_{$year}"> 
    <tr> 
     <th><$mt:Var name="year"$></th> 
    <mt:For var="month" from="1" to="12"> 
      <mt:SetVarBlock name="monthYear"><$mt:Var name="month" sprintf="%02d"$><$mt:Var name="year"$></mt:SetVarBlock> 
     <td> 
      <$mt:Var name="links_{$monthYear}" setvar="month_link"$> 
      <mt:If name="month_link"> 
       <$mt:Var name="month_link"$> 
      <mt:Else> 
       <$mt:Var name="month_map{$month}"$> 
      </mt:If> 
     </td> 
    </mt:For> 
    </tr> 
    </mt:If> 
</mt:For> 
</table> 
Questions connexes