Skip to content

Instantly share code, notes, and snippets.

@nataliepo
Created February 21, 2011 20:56
Show Gist options
  • Save nataliepo/837691 to your computer and use it in GitHub Desktop.
Save nataliepo/837691 to your computer and use it in GitHub Desktop.
i always forget the syntax for mt templates using the <mt:for> tag.
<ul class="gallery">
<mt:setvarblock name="num_assets"><$MTNumAssets$></mt:setvarblock>
<mt:setvarblock name="num_assets"><mt:var name="num_assets" op="++"></mt:setvarblock>
<!-- num assets = <mt:var name="num_assets"> -->
<MTIfHasAsset placement="1">
<!-- Has a numbered asset! -->
<mt:for var="i" from="1" to="$num_assets" increment="1">
<mt:AssetContainer placement="$i">
<mt:SetVarBlock name="caption"><mt:AssetDescription encode_html="1"></mt:SetVarBlock>
<mt:AssetProperty property="image_width" setvar="this_width">
<li<mt:If name="i" eq="1"> class="active"</mt:If>>
<img src="<mt:If name="this_width" gt="500"><mt:AssetThumbnailURL width="500"><mt:Else><mt:AssetURL></mt:If>" title="<mt:Var name="caption">" alt="<mt:Var name="caption">">
</li>
</mt:AssetContainer>
</mt:for>
<MTElse>
<!-- Does not have a numbered asset! -->
<mt:EntryAssets tag="@gallery">
<mt:SetVarBlock name="caption"><mt:AssetDescription encode_html="1"></mt:SetVarBlock>
<mt:AssetProperty property="image_width" setvar="this_width">
<li<mt:If name="__first__"> class="active"</mt:If>>
<img src="<mt:If name="this_width" gt="500"><mt:AssetThumbnailURL width="500"><mt:Else><mt:AssetURL></mt:If>" title="<mt:Var name="caption">" alt="<mt:Var name="caption">">
</li>
</mt:EntryAssets>
</MTIfHasAsset>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment