<mt:ParentCategory>

A container tag that creates a context to the current category’s parent, if category is assigned a parent category.

Example ΒΆ

List all the categories and link to parent category if category in context has a parent category:

<ul>
<mt:Categories>
    <li>
    <a href="<mt:ArchiveLink>"><mt:CategoryLabel></a>
    <mt:ParentCategory>
        (Parent Category: <a href="<mt:ArchiveLink>"><mt:CategoryLabel></a>)
    </mt:ParentCategory>
    </li>
</mt:Categories>
</ul>

block, category, template tag

This page was last updated on 2009-11-13, 18:37. [Edit]

1 Note

To display contextual ads for entries depending on the categories, you can use the code snippet below in the entry archive template. Do not forget to create a category custom field "Contextual Ad" .

<mt:ignore>set the primary category ad</mt:ignore>
<$mt:EntryCategory setvar="main_entry_category"$>
<mt:EntryCategories>    
    <mt:IfCategory label="$main_entry_category">  
        <mt:If tag="categorydatacontextual_ad">
            <mt:SetVarBlock name="main_category_ad"><div id="contextual-ad-container"><mt:categorydatacontextual_ad></div></mt:SetVarBlock>
            <mt:SetVar name="ad_found" value="1"> 
        </mt:If>
    </mt:IfCategory>  
</mt:EntryCategories>

<mt:ignore>set the parent category ad</mt:ignore>
<mt:ParentCategory>
    <$mt:CategoryLabel setvar="main_parent_category"$>
    <mt:If tag="categorydatacontextual_ad">
        <mt:SetVarBlock name="main_parent_ad"><div id="contextual-ad-container"><mt:categorydatacontextual_ad></div></mt:SetVarBlock>
    </mt:If>
</mt:ParentCategory>

<mt:ignore>output the contextual ads</mt:ignore>
<mt:If name="ad_found" eq="1">
   <mt:Var name="main_category_ad">
<mt:Else>
    <mt:Var name="main_parent_ad">    
</mt:If>

Leave a note

Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.