afinta

Using ifCategory in the Category Entry Listing template

Vote 0 Votes

Long time since I have been here - I hope someone is paying Mihai!

So - I have a Category Entry Listing template and having some issues.

Basically the header and footer are the same, but inside the template I have this:

<mt:IfCategory Label="Trattamenti Medico-Estetici">
<mt:SubCategories>
<div class="category-headers"><a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a></div>
<mt:Entries sort_by="title" sort_order="ascend">
<div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>   
</mt:Entries>
</mt:SubCategories>
<mt:Else>
<mt:Entries sort_by="title" sort_order="ascend">
<div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>   
</mt:Entries></mt:IfCategory>

But I have not been able to alter that to do the following - I have one category that I don't want to show any entries for.
No matter what I tried, something did not work - either all the entries disappeared, or they didn't when I thought they would, etc.

I think I need something like if this category do this, else do this for this specific category, else do this for all the rest. I just can't figure it out!

Any ideas?

Reported on Movable Type 4.3

3 Replies

| Add a Reply
  • Hello Afinta,

    Nobody pays me, but I am happy to provide feedback here from time to time and people that need more advanced work are also coming back to me for consultancy, or for various jobs (upgrades, new features etc.).

    Assuming that you wanted me to adapt the above to let you declare a category for which you don't want any entries displayed, I could advice you to use:

    <mt:IfCategory label="Trattamenti Medico-Estetici">
    <mt:SubCategories>
    <div class="category-headers"><a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a></div>
    <mt:Entries sort_by="title" sort_order="ascend">
    <div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>
    </mt:Entries>
    </mt:SubCategories>
    <mt:Else>
    <mt:IfCategory label="None from this other category">
    <mt:Else>
    <mt:Entries sort_by="title" sort_order="ascend">
    <div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>
    </mt:Entries>
    </mt:IfCategory>
    </mt:IfCategory>

    Or in a simplified format it could be:

    <mt:IfCategory label="None from this other category">
    <mt:Else>
    <mt:IfCategory label="Trattamenti Medico-Estetici">
    <mt:SubCategories>
    <div class="category-headers"><a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a></div>
    <mt:Entries sort_by="title" sort_order="ascend">
    <div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>
    </mt:Entries>
    </mt:SubCategories>
    <mt:Else>
    <mt:Entries sort_by="title" sort_order="ascend">
    <div class="entry-list"><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></div>
    </mt:Entries>
    </mt:IfCategory>
    </mt:IfCategory>

    Where "None from this other category" is the label of the category for which you don't want to display any entries.

    This could be done also in a different away, checking the current category against the ArchiveTitle tag, but I don't want to complicate your life.

    The above should work!

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/
    ----------------------------------

    Open Melody Demo
    http://www.openmelodydemo.org/

  • Thanks Mihai - I will try this and let you know.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1774 6167

Last Topic: Template modules by Zielun on Feb 16, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1434 5088

Last Topic: Maintenance announcement by Nick on Feb 17, 2012

695 2912

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

174 740

Last Topic: Captcha images rendering slowly by ScottM on Feb 12, 2012

190 568

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012