Question

I'm trying to insert UL on every 20th sub category label. This code below doesn't seem to work. It only exports list of sub categories without the UL in it's right place.

Any one know what would be wrong?

<MTTopLevelCategories>
<ul>
<MTSubCategories>
<mt:If name="__counter__" op="%" value="20" eq="1">
<mt:If name="__counter__" ne="1">
</ul>
<ul></mt:If></mt:If>
<li><$MTCategoryLabel$></li>
</MTSubCategories>
</ul>
</MTTopLevelCategories>

My testing environment: Movable Type 5.01 PHP 5.2.11 MySQL 5 Perl 5.8.9

Was it helpful?

Solution

From what I recall and according to the "Proposal:Iterator template tag consistency" wiki page, the __counter__ meta variable is not available under <mt:SubCategories>. Unfortunately, MT lacks consistent use of the meta variables, but you can create your own counter variable to do the same thing.

<MTTopLevelCategories>
  <$mt:SetVar name="subcatcount" value="1"$>
  <ul>
    <MTSubCategories>
      <mt:If name="subcatcount" op="%" value="20" eq="1">
        <mt:If name="subcatcount" ne="1">
          </ul>
          <ul>
        </mt:If>
      </mt:If>
      <li><$MTCategoryLabel$></li>
      <$mt:SetVar name="subcatcount" value="1" op="add"$>
    </MTSubCategories>
  </ul>
</MTTopLevelCategories>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top