Help - Search - Members - Calendar
Full Version: Mt4 As A Cms
Movable Type Community Forum > Additional Resources > Tips and Tricks
caribou sue
I've been using MT as a CMS for a few years, and MT4 has made it far easier. Here are some tips and tricks I've put together on using MT4 to power an entire site. Please add your own!

1. Pages, entries, folders and categories: understanding the pieces of MT
For anyone serious about using MT as a CMS, I'd advise looking at the default templates provided, then ditching them and starting fresh. (Don't worry, you can always find them again here.) You'll learn more about how it all works, and you can build in as much flexibility as you need.


* Pages are the most important part of the CMS. They form the relatively static meat-and-potatoes of your site. Examples: About Us, Contact, Staff, Financial info... you get the idea. Pages differ from entries in that they simply present information, and may not be updated often.
* Folders are key for structing your site. All pages about your organization may go in one folder, pages about your work and mission in another, and pages about your publications in a third. Depending on how big your site is, you may even have subfolders. Remember that the key page in each folder should have the basename index.
* Entries are for constantly updating information. You can use entries for a news feed or a blog, for example.
* Categories, like folders, are a way of organizing your entries. They're not necessary, though -- you might prefer tags instead.
* Index templates can be full of MT template tags. These are great for Home pages, where you can bring together a bunch of updating content. They're also handy for CSS and RSS files.


Your finished site might look like this:

Home (index template)
About (folder)

* About us (page)
* Our mission (page)
o Financials (subfolder)
+ Financials (page)
+ Annual reports (page)

Blog (folder)
*Blog (index template bringing entries together, or a page with template tags (use processtags plugin)
caribou sue
2. Navigation
Now you have a structure for your site, so how do visitors navigate around it? You can create top-level navigation by outputting a list of all the top-level folders:

CODE
<ul>
<MTToplevelFolders>
<li><a href="<MTBlogURL><MTFolderPath>"><MTFolderLabel></a></li>
</MTToplevelFolders>
</ul>


On each page, you can show the other pages and subfolders within the current folder:

CODE
<mt:setvarblock name="currentfolder"><MTPageFolder><MTFolderLabel></MTPageFolder></mt:setvarblock>

<ul>
<MTPageFolder>
  <MTPages folder="$currentfolder">
     <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>


And a trail of breadcrumbs on each page will help visitors understand where they are in your site:

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


If you want to see your whole navigational structure in one place, as in a sitemap, try:

CODE
<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>
danwolfgang
You might consider adding your code tidbits to the Cookbook. Thanks for the tips, BTW.
gspatel
Added to the cookbook template tag recipes, with full credit to caribou. Brilliant work, caribou!

Have also added this: a listing of all pages, sub-folders and pages in sub-folders except the current page. This is conceivably useful in a sidebar listing.

CODE
<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> »</a>
<ul>
<MTPages><li><a href="<MTPagePermalink>"><MTPageTitle></a></li></MTPages>
<MTSubFolderRecurse>
</ul>
</li>
</MTSubFolders>
</MTPageFolder>
</ul>


Incidentally, note the horrible error in the MT Template Tag Reference Documentation on the <SubFolderRecurse> tags. That code reads:

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>


This is totally wrong. There's no such thing as <MTSubFolderIsFirst>, <MTSubFolderIsLast> or <MTFolderArchiveLink> (what the heck is that, even conceptually?) tags.
Su-
QUOTE (gspatel @ Dec 16 2007, 12:12 AM) *
There's no such thing as <MTSubFolderIsFirst>, <MTSubFolderIsLast> or <MTFolderArchiveLink> (what the heck is that, even conceptually?) tags.

You reported these via the feedback form, right? You apparently didn't leave a comment on that page, either, which also would be helpful.

The tags should exist, and were apparently left out of the release. They were presumably intended(at some point at least), or how would they have ended up in the docs?

FolderArchiveLink would be a link to a page corresponding to that folder. Folders are, by and large, functionally equivalent to categories for entries. What's your conceptual problem with that? I'm not sure there's a proper archive type for it right now, though, unless they get bunched in with cat archives(which wouldn't seem right to me, but hey).
caribou sue
Thanks guys, I'm glad you find it helpful. smile.gif
samiton
Thank you caribou for you great info!! Very helpful!!
deeleea
This looks great, and appears to be exactly what I need, but for the life of me, implementing it doesn't give me the promised results!! I'd love some input from someone as to where I'm going wrong!

I want to use this code to spit out a sub menu of pages relevant to the folder they're in - but using this code 'as is' returns a list of page names, some of which aren't actually in the folder. Of course the code is applying the site name and folder name to the url so the list doesn't necessarily create relevant links either... ( I have removed subfolder relevant information as I'm not using subfolders)

CODE
<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>
</MTPageFolder>
</ul>


I can get something approximating what I want if I use the following.
CODE
<div id="pagesidebar"><img src="<MTBlogURL>images/sidebar1top.gif" />
<MTPageFolder><h3><MTFolderDescription></h3>
<div id="navcontainer"><ul>
<mt:setvarblock name="curpage"><mt:pageid></mt:setvarblock>
<MTPages folder="1-about" sort_by="title" sort_order="ascend">
<mt:setvarblock name="listpage"><mt:pageid /></mt:setvarblock>
<mt:unless name="listpage" eq="$curpage">
<li><a href="./<MTPageBasename>.html" id="<MTPageBasename>"><MTPageTitle></a></li>
</mt:unless>
</MTPages>
</MTPageFolder>
</ul></div><!--end div navcontainer-->
<img src="<MTBlogURL>images/sidebar1bottom.gif" /></div>
<div id="mainContent">


You can see that the only difference is that I've put a folder attribute in the MTPages tag. This brings up the correct list BUT, clearly brings up the SAME list on all of the pages so it isn't specific to the folders... I've tried replacing the folder attribute with various folder template tags line MTFolderDescription or MTFolderLabel but then the list disappears altogether.

I'm making really good strides figuring this kind of thing out on my own but I've come up stumped and I'm running out of time... so I'm hoping I can draw out an answer here!

Can anyone offer any insight into where I'm going wrong? if it helps the folder structure looks like this

6 folders all labelled using the following syntax
1-[Label]
2-[Label] etc (so they're in the order I want)

One word descriptions applied to each folder which are being used as the navigation titles.

21 pages in total. all stored in the correct folder, none of which have tags, and all of which are published.

Not even sure if I'm giving you TMI but I figure every bit helps...

Thanks in advance!

Deeleea
caribou sue
Hi Deeleea,
I think I see what's happening. When you use MTPageFolder tags, MT only applies that context to folders. If you ask for a list of pages within MTPageFolder, it will look for all pages in all folders. Kind of unintuitive!

The easy workaround is to set the current folder as a variable at the top of your page template:
CODE
<mt:setvarblock name="curfolder"><MTPageFolder><MTFolderLabel></MTPageFolder></mt:setvarblock>


And then list your pages with:

CODE
<MTPages folder="$curfolder">
<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>

deeleea
Caribou, that was perfect, thanks - I've used MT3 in its barest form on my blog for years, but between tweaking MT4 on a mate's site and this post of yours I'm finally using it (MT4 now) as a CMS for a client... I got all enthusiastic at how coool the new version is it is and how easy you made it sound!!! I am LOVING it and it's totally working for both of us.

As for this problem? I'd got close - figured a variable was the answer but I wasn't setting it in the right place.

Nice work, thanks for your help.
jeffm2
I am attempting to use MT4 as a CMS for users who are not very knowledgeable. I am trying to figure out a way to enable them to edit/add links to their navigation through the MT WYSIWYG to eliminate any need for any other kind of software (Frontpage, etc)
Currently the menu is a server side include.

Anyway to make it a widget that can be edited with a WYSIWYG and not see any code/tags? Or somehow edit it like a page or entry?
caribou sue
QUOTE (jeffm2 @ Apr 9 2008, 12:31 PM) *
I am attempting to use MT4 as a CMS for users who are not very knowledgeable. I am trying to figure out a way to enable them to edit/add links to their navigation through the MT WYSIWYG to eliminate any need for any other kind of software (Frontpage, etc)
Currently the menu is a server side include.

Anyway to make it a widget that can be edited with a WYSIWYG and not see any code/tags? Or somehow edit it like a page or entry?


You can generate a menu on each page template using the folder structure. That means teaching users how folder structures work, but it results in less chaotic sites overall.

For includes, I'm not sure -- the bits of MT that make good includes (index templates and template modules) aren't WYSIWYG editable. I guess you could have a page that publishes to your includes folder, and bookmark it so they can just edit that.
jeffm2
normally the "use a page that publishes to the includes folder" would work i think, but I already have a page template. i would need another that contains no header, footer, etc but when you generate a page you can't dictate which template to use (right?).
What i mean is if this "include page" gets rebuilt or saved the system will pick the default page template.

anyway around this?
caribou sue
QUOTE (jeffm2 @ Apr 10 2008, 05:32 AM) *
normally the "use a page that publishes to the includes folder" would work i think, but I already have a page template. i would need another that contains no header, footer, etc but when you generate a page you can't dictate which template to use (right?).
What i mean is if this "include page" gets rebuilt or saved the system will pick the default page template.

anyway around this?


Right, good point. :-) Hmm. Another possibility is an index page that's linked to a file, then let your users update the file with an external WYSIWYG editor? Teach them the magic of a href so they can be all empowered about editing the HTML themselves? MT is still kind of tricky to teach to non-web-savvy folks.
deeleea
Hey Caribou, hope you don't mind answering another question... but I'm keen to insert code so that the current page is shown up in a different colour/style in the menu than the other menu items. How do I incorporate class specific tags like adding a "selected" or "on" class to the current menu item so the output code looks like this?

CODE
<div id="vdividermenu">
<ul>
[abridged code]
<li><a href="[siteurl]/site/resources/index.html">resources</a></li>
<li><a class="selected" href="[siteurl]/site/contact/index.html">contact</a></li>
</ul>


The MT code looks like this...

CODE

<div id="vdividermenu">
<ul>
<li><a href="<MTBlogURL>index.html">HOME</a></li>
<MTToplevelFolders sort_by="desc" sort_order="ascend">
<li><a href="<MTBlogURL><MTFolderBasename>/index.html"><MTFolderDescription></a></li>
</MTToplevelFolders>
</ul>
<!-- end the menuh div --> </div>


Thanks in advance... biggrin.gif
caribou sue
Hi deeleea,
You can do this using MTIf to give the current page a different CSS class. Here's how I did something similar on a site:

First, I set some variables on the page archive template.
CODE
<MTSetVarBlock name="thispage"><MTPageTitle></MTSetVarBlock>
<MTSetVarBlock name="thisfolder"><MTPageFolder><MTFolderLabel></MTPageFolder></MTSetVarBlock>


In the subnavigation for each page, the page we're currently on is given the class "current".
CODE
<ul>
  <MTPages folder="$thisfolder">
  <MTSetVarBlock name="listpage"><MTPageTitle></MTSetVarBlock>
     <MTIf name="thispage" eq="$listpage">
     <li class="current"><MTPageTitle></li>
        <MTElse>
        <li><MTPageTitle></li>
        </MTElse>
    </MTIf>
  </MTPages>
</ul>


Since you're listing top level folders instead of pages, you would just need to tweak your variables accordingly.
Hope that helps!
bruce21
QUOTE
For anyone serious about using MT as a CMS, I'd advise looking at the default templates provided, then ditching them and starting fresh.


Cariboo, how refreshing to see this comon sense approach! And so true, one can replace the default templates quite easily, even going back to indiv, monthly and category archives sim to 3x, but even more simplified.
Your tutorials are encouraging me that one shouldn't give up or be negative towards MT, simply change what bugs one smile.gif
caribou sue
QUOTE (bruce21 @ Apr 28 2008, 12:46 AM) *
QUOTE
For anyone serious about using MT as a CMS, I'd advise looking at the default templates provided, then ditching them and starting fresh.


Cariboo, how refreshing to see this comon sense approach! And so true, one can replace the default templates quite easily, even going back to indiv, monthly and category archives sim to 3x, but even more simplified.
Your tutorials are encouraging me that one shouldn't give up or be negative towards MT, simply change what bugs one smile.gif


Thanks, fellow Ontarian! I find the default templates way too complicated for someone dipping their toes into MT for the first time. Heck, I've been using it for 4 years, and I have trouble following them.
deeleea
QUOTE (caribou @ Apr 17 2008, 01:49 PM) *
Hi deeleea,
You can do this using MTIf to give the current page a different CSS class. Here's how I did something similar on a site:

First, I set some variables on the page archive template.
CODE
<MTSetVarBlock name="thispage"><MTPageTitle></MTSetVarBlock>
<MTSetVarBlock name="thisfolder"><MTPageFolder><MTFolderLabel></MTPageFolder></MTSetVarBlock>


In the subnavigation for each page, the page we're currently on is given the class "current".
CODE
<ul>
  <MTPages folder="$thisfolder">
  <MTSetVarBlock name="listpage"><MTPageTitle></MTSetVarBlock>
     <MTIf name="thispage" eq="$listpage">
     <li class="current"><MTPageTitle></li>
        <MTElse>
        <li><MTPageTitle></li>
        </MTElse>
    </MTIf>
  </MTPages>
</ul>


Since you're listing top level folders instead of pages, you would just need to tweak your variables accordingly.
Hope that helps!



Wow, great stuff, thanks heaps!
deeleea
QUOTE (caribou @ Apr 17 2008, 01:49 PM) *
Hi deeleea,
You can do this using MTIf to give the current page a different CSS class. Here's how I did something similar on a site:

First, I set some variables on the page archive template.
CODE
<MTSetVarBlock name="thispage"><MTPageTitle></MTSetVarBlock>
<MTSetVarBlock name="thisfolder"><MTPageFolder><MTFolderLabel></MTPageFolder></MTSetVarBlock>


In the subnavigation for each page, the page we're currently on is given the class "current".
CODE
<ul>
  <MTPages folder="$thisfolder">
  <MTSetVarBlock name="listpage"><MTPageTitle></MTSetVarBlock>
     <MTIf name="thispage" eq="$listpage">
     <li class="current"><MTPageTitle></li>
        <MTElse>
        <li><MTPageTitle></li>
        </MTElse>
    </MTIf>
  </MTPages>
</ul>


Since you're listing top level folders instead of pages, you would just need to tweak your variables accordingly.
Hope that helps!



Sorry for the late reply, finally got things where I want them. Really appreciate the advice thanks heaps!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.