Isaac Sarayiah

Having Categories Displayed on Main (Index) Page

Vote 0 Votes

Hi
My website is http://www.theSarayiahpost.com and I am thinking about having the categories I have created displayed on the main index page. Can someone tell me how to do that please?

Thank you.
Kind regards
Isaac Sarayiah

Reported on Movable Type 5

5 Replies

| Add a Reply
  • ~x(

    <h2><$MTCategoryLabel$></h2>
    <ul>
    <MTEntries>
    <li><a href="<MTEntryPermalink>"><MTEntryTitle></a></li>
    </MTEntries>
    </ul>

  • Hi Isaac,

    Discard Masoud coding above, because that is for listing the current category name and the entries under it in a category context.

    What you need is:

    You may like to use the following coding if you want to list all categories that have at least one item under them:

    <ul>
    <mt:Categories>
    <li><a href="<mt:CategoryArchiveLink>"<mt:If tag="CategoryDescription"> title="<mt:CategoryDescription remove_html="1" encode_html="1">"</mt:If>><mt:CategoryLabel> (<mt:CategoryCount>)</a></li>
    </mt:Categories>
    </ul>

    If you want to display also the ones without no entries associated to them, then use:

    <ul>
    <mt:Categories>
    <mt:If tag="CategoryCount">
    <li><a href="<mt:CategoryArchiveLink>"<mt:If tag="CategoryDescription"> title="<mt:CategoryDescription remove_html="1" encode_html="1">"</mt:If>><mt:CategoryLabel> (<mt:CategoryCount>)</a>
    <mt:Else>
    <li><mt:CategoryLabel>
    </mt:If>
    </li>
    </mt:Categories>
    </ul>

    And if you want to show the top categories and all their subcategories in a format which would allow you indend sub-categories, then use:

    <mt:TopLevelCategories>
    <mt:SubCatIsFirst>
    <ul>
    </mt:SubCatIsFirst>
    <mt:If tag="CategoryCount">
    <li><a href="<mt:CategoryArchiveLink>"<mt:If tag="CategoryDescription"> title="<mt:CategoryDescription remove_html="1" encode_html="1">"</mt:If>><mt:CategoryLabel> (<mt:CategoryCount>)</a>
    <mt:Else>
    <li><mt:CategoryLabel>
    </mt:If>
    <mt:SubCatsRecurse>
    </li>
    <mt:SubCatIsLast>
    </ul>
    </mt:SubCatIsLast>
    </mt:TopLevelCategories>

    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/

    • Hi Mihai
      1) Thank you for that. Can you tell me where I put that code or do I create a widget for it and put that in the primary sidebar on the main website(which is where I would want it displayed).

      2) Also, Mihai can you tell me how to have each entry that is displayed on the main (index) page to show the "Posted to [name of category/categories]" at the bottom of each entry?

      Kind regards
      Isaac Sarayiah


  • You're welcome!

    1) You will have to put that code where you would like it to appear.

    If it is inside the content column, then you should add it to the "Main Index" template.

    If it is inside the sidebar, then it depends on your template set, which widget or module is the right one for it. A hint here is to first go to your "Main Index" template, then to look if it includes a module called "Sidebar" or "Footer" and to follow that path until you find the sidebar items and pick one where to put that logic.

    Or create a new module or widget and add it to the sidebar...

    2) You would first have to go to the "Main Index" template and see how it references the entries, probably it includes the "Entry Summary" template module.

    Then go inside that place and use something like:

    2.1) the following for calling the primary category only

    "Posted to ">"

    2.2) or the following for displaying all the categories assigned to that entry

    "Posted to ">"

    Enjoy,
    Mihai

  • Hi Mihai
    I can't get your code for displaying the categories on the main index page in the side bar to work. It doesn't display anything.

    I created a new widget module and then saved that to the primary sidebar but once I've published it, nothing is dispalyed.

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