MasonAndMovableType


Warning: These wiki pages have not been edited in years and may well be out of date/inaccurate. We recommend that you use them as a starting point for further investigation, rather than gospel.
A question was asked recently on the mason-users mailing list about using Mason and MovableType for weblogging:
http://marc.theaimsgroup.com/?t=107841954100004&r=1&w=2
I replied with a mail, but it's not archived, so here is another explanation of how I do it. This is just one method that I happened to use. Your mileage may vary. ]



I use Mason and MT together to create sites that use MT as a content management system where some pages are generated by MT and some are not. The way that I do it is to make my MT software spit out Mason components. I have stripped out all of the header and footer stuff from the regular MT templates and put that into an autohandler. In the middle of the autohandler is a <% $m->call_next %> which ensures that the component made by MT will appear in there.



For instance, my individual archive page template in MT contains the regular HTML necessary to make a page. The template is missing all of stuff now found in autohandler. MT reads that template, and spits out a file with the guts of my weblog in it. When this page is requested, Mason serves it by gluing it inside the autohandler.

So far it's not very interesting since Mason is only gluing back together a page that we ripped apart in the first place. We really haven't gained anything except Mason is operating on files produced by MT. Now we can start to do cool things. Let's make the titles of our pages dynamic.


In your individual archive template, make a Mason method definition like:

<%method title><$!MTEntryTitle$></%method>

Once MT gets ahold of this, it makes a file with something like this in it:

<%method title>This is a weblog entry title</%method>

In your autohandler, use code like:

<title>My weblog: <& SELF:title &></title>

to define your title. Now when Mason gets ahold of this you'll have a dynamic title in your web pages. You have one autohander, but it looks to the page generated by MT to determine the title. This still isn't much more than we could do with MT alone, but we're getting closer.

Now, lets serve ads on each page. In my individual archive template, I have a Mason method definition like this:

<%method category><$!MTEntryCategory$></%method>

This defines a Mason method named "category" that will always return the name of the category that this article belongs to.

Then, in my autohandler, I have a call to a Mason component like this:

% $m->comp( '/ads/categoryad', category=>$m->scomp( 'SELF:category' ) );

That way, the Mason component "/ads/categoryad" gets called with an argument that represents the current category. That Mason component happens to be smart enough to select advertisemnts based on the category of the individual story. Now I can have rotating ads that differentiate themselves based on the category of the current story.

I suppose I could have written a MT plugin to do this, but I use the same Mason components to serve ads in other parts of my site that aren't driven by MT. This is a handy way to make sure that my pages all look uniform, wether they're MT generated pages or not.

These are two examples of how I glue MT generated content into my Mason powered site. I end up using MT as a content management database, and keep the look and feel of the site defined in my autohandler and other Mason components.

I'm interested in hearing how other people have used Mason and MT together, so please share your stories.