Breadcrumbs - movabletype/Documentation GitHub Wiki

Table of Contents

Breadcrumbs for pages and folders

On an MT4+ powered site that has pages and folders, the following code delivers a completely effective breadcrumb navigation trail:

<a href="<MTBlogURL>">Home</a> &raquo;
<MTParentFolders> 
  <a href="<MTBlogURL><MTFolderPath>"><MTFolderLabel></a> &raquo;
</mtparentfolders>
<strong><MTPageTitle></strong>

Sidebar listing of folders/pages

Error in MT Template Tag Reference Appendix Documentation for SubFoldersRecurse

The MT4 documentation on the tag has an error in the code:

<MTTopLevelFolders>
  <MTSubFolderIsFirst><ul></mtsubfolderisfirst>
    <MTIfNonZero tag="MTFolderCount">
        <li><a href="<$MTFolderArchiveLink$>"
        title="<$MTFolderDescription$>"><MTFolderLabel></a>
    <MTElse>
        <li><MTFolderLabel>
    </mtelse>
    </mtifnonzero>
    <mt:SubFolderRecurse>
    </li>
<MTSubFolderIsLast></ul></mtsubfolderislast>
</mttoplevelfolders>

There's simply no such thing as

<MTSubFolderIsFirst>, <MTSubFolderIsLast> and <MTFolderArchiveLink>
(duh?) tags.

Recipe 1: List all pages and folders in the system

This will list all pages (contained in a folder) and folders across the weblog.

<ul>
<MTTopLevelFolders>
    <li><a href="<MTFolderPath>"><MTFolderLabel></a></li>
    <ul>
    <MTPages>
    <li><a href="<MTPagePermalink>"><MTPageTitle></a></li>
    </mtpages>
    </ul>
    <ul><MTSubFolderRecurse></ul>
</mttoplevelfolders>
</ul>

Recipe 2: List only folders, not pages

This lists only the folders and sub-folders, but no pages.

<ul>
<MTTopLevelFolders>
    <li><a href="<MTFolderPath>"><MTFolderLabel></a></li>
    <ul>
    </ul>
    <ul><MTSubFolderRecurse></ul>
</mttoplevelfolders>
</ul>

Recipe 3: List only top level folders

This lists only the top level folders, no sub-folders or pages.

<ul>
<MTToplevelFolders>
<li><a href="<MTBlogURL><MTFolderBasename>/index.php"><MTFolderLabel></a></li>
</mttoplevelfolders>
</ul>

Recipe 4: List all pages and sub-folders in the present folder

Conceivably useful in a sidebar on every page, this lists all the pages and sub-folders in the present page folder. Note that it also lists the current page.

<ul>
<MTPageFolder>
  <MTPages sort_by="date">
     <li><a href="./<MTPageBasename>.php" id="<MTPageBasename>"><MTPageTitle></a></li>
  </mtpages>
  <MTSubFolders>
   <li><a href="<MTBlogURL><MTFolderPath>/index.php"><MTFolderLabel>  &raquo;</a>
      <ul>
        <MTPages><li><a href="<MTPagePermalink>"><MTPageTitle></a></li></mtpages>
        <MTSubFolderRecurse> 
    </ul>
     </li>
  </mtsubfolders>
</mtpagefolder>
</ul>

Recipe 4.5: List all pages except the current page and sub-folders in the present folder

This works very well. It eliminates the current page from the listing, and lists all the other pages, sub-folders and sub-folder pages in the present page folder.

<ul>
<mt:setvarblock name="curpage"><mt:pageid></mt:setvarblock>
<MTPageFolder>
  <MTPages sort_by="title" sort_order="ascend">
  <mt:setvarblock name="listpage"><mt:pageid /></mt:setvarblock>
  	<mt:unless name="listpage" eq="$curpage">
     <li><a href="./<MTPageBasename>.php" id="<MTPageBasename>"><MTPageTitle></a></li>
     </mt:unless>
  </mtpages>
  <MTSubFolders>
   <li><a href="<MTBlogURL><MTFolderPath>/index.php"><MTFolderLabel>  &raquo;</a>
      <ul>
        <MTPages><li><a href="<MTPagePermalink>"><MTPageTitle></a></li></mtpages>
        <MTSubFolderRecurse> 
    </ul>
     </li>
  </mtsubfolders>
</mtpagefolder>
</ul>

CREDITS

Almost all of this is from caribou's post at the sixapart forums.

--Gautam Patel 22:03, 15 December 2007 (PST)

⚠️ **GitHub.com Fallback** ⚠️