Using module template for a "archive mapping"

| No Comments | No TrackBacks

Hajime Fujimoto, well-known MT master in Japan, had wrote about the way of using module template for a "archive mapping".

With his method, you can define complex conditional archive mapping in the archive template.

I will introduce his entry with some modification.

At first, let's say that;

*Blog id is no.1
* The blog has "news" category and "products" category at the top level, and they have descendant categories with each.
*You want to set your archive pass like "http://www.sample.com/news/subcategories/year/month/day/%h%m%s.html" when it belongs to "news" category.
*You want to set your archive pass like "http://www.sample.com/products/subcategories/arbitrary-name.html" when it belongs to "products" category.
*Every entry belongs to only one category.

Okay, let's make a module template named "orginal-archive-pass" and write as this.

 

<MTUnless regex_replace="/\s+\n/g","\n">

<mt:EntryCategories>

<mt:IfIsDescendant parent="news">

    <$mt:FileTemplate format="%c/%y/%m/%d/%h%n%s%x"$>

  </mt:IfIsDescendant>

  <mt:IfIsDescendant parent="products">

    <$mt:FileTemplate format="%c/%b%x"$>

  </mt:IfIsDescendant>

</mt:EntryCategories>

</MTUnless>

Then, please indicate the module template in your archive mapping form.

<mt:Include module="original-archive-pass" blog_id="1">

The file name of entries will be determined by conditional branching defined in "original-archive-pass" template.

Please give it a try.

No TrackBacks

TrackBack URL: http://www.mt-j.info/mt/mt-tb.cgi/101

Leave a comment

About this Entry

This page contains a single entry by nick published on April 7, 2010 10:00 PM.

The topic from MT.forum, "Is Movable Type5 dead?" was the previous entry in this blog.

“Movable Type EZ”, a SaaS of MT is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.