Help - Search - Members - Calendar
Full Version: Trick (& Help) - Individual Category Templates
Movable Type Community Forum > Additional Resources > Tips and Tricks
morbus
The more I looked into this, the less I thought it'd be possible. After rereading the instruction and seeing that "Some Movable Type tags are context-sensitive", it made sense that an MTEntries category="" would be repetitive within a Category Archive.

So, I cheated and jumped out of MT, and decided to use server side includes instead (which I already use throughout the Gamegrene.com site). Now, I use the following bit of code to dynamically create an SSI instruction keyed to the category name. Then, I have various files named after the categories which contain just the bit of individualistic template text I need.

CODE
<!--#include virtual="../mt_templates/category_<$MTEntryCategory dirify="1"$>.info" -->


This is a lot more scaling than the other alternative I presented above (as it really only requires adding a new "category_CATEGORYNAME.info" file for each new category you create).

Hey, works for me! Probably the best (easiest?) way to duplicate this within MT would be to double decode the $MT$ tags (so that one could embed an $MT$ tag within an $MT$ tag itself. This, however, is a pretty rare feature that anyone would use. Perhaps the better suggestion would be to make *every* MT tag parsable within any context/archive. If the user shoots themselves in the foot, than so be it. But for people like me, I could have used that bit of hackery within MT, as opposed to jumping into another tech (SSI, in this case).
Teel
I am actually trying to rebuild a site using MT, and would love some way of being able to use multiple-interpolation of MT tags.  For instance, I am using categories to delineate between different sections (ie: Movie Reviews, Poetry) as well as between different online comics (I currently host ten different online comics, each with its own archive), and I would like to be able to offer Next/Previous entry within the category of the individual entry page that is being viewed.  So, if you're looking at a comic somewhere in the "Diablo" series, next would go to the next Diablo comic, not just the next thing that happened to be posted on the site.  Not just category, either, but sometimes also Author so that if someone is reading peotry on the site, they could choose between "next poem" and "next poem by this author" instead of just "next thing posted on the site".

Also, I currently have drop-down menus on every individual page of my site that list what amounts to every entry in that particular category, and would love to be able to use MT to do the same thing, but every attempt I have made seems to require MT tags to be interpolated more than once.  Even the original problem posed, of wanting different lead-in information for different headers would be solved if I could say
CODE
<$MTInclude module="<$MTEntryCategory$>"$>


Obviously, I could just set up dozens of different blogs and tie them all together with a bunch of SSI and manually updated files, but that would be just as easy to work with as what I already have.  Or, maybe I'm just missing some obvious way to do what I want.  Thanks for any help anyone can offer.

(Note: I have a head cold right now, so if I didn't make myself clear, I'll try again when it's passed in a couple of days.)
muta
ok, I'm back. I found a messy solution to the problem (how, on an individual archive page, to generate a list of entries that share that entry's category).

a) for each category type, create an index template, something along the lines of:

CODE
<MTEntries category="flowers"><a href="<$MTEntryLink$>"><$MTEntryTitle$></a><br></MTEntries>


b) then, in the Individual entry archive template, include the file generated in step a) with a server side include.

The only reason I don't consider this a clean solution is that there's no way to distinguish what page you're viewing and modify the list appropriately.. so even if I'm on the 'daisy' page in the 'flowers' category, my generated list will include a link to the 'daisy' page.
morbus
Hey there. I'm using Movable Type to try to duplicate Gamegrene.com, which is currently being run by an old, decrepit homebrew CMS.

One of the things that this CMS lets me accomplish is different templates for each category. I use this feature to preface a little "intro to this category" for each individual archive that gets place into said catergory.

I discovered a trick to do this within MT, which is quite simple. If you're using Category Archives, you can blurb a bit of category specific text in your template by doing something like:

CODE
<MTEntries category="Interviews">
  super special "Interviews" only text
</MTEntries>


And then you'd go ahead and use the rest of the MTEntry tags to customize the rest of the template. In the above case, the above text would ONLY appear if the blog entry was contained within the "Interviews" category.

Sidenote: This quickly gets wordy. In my case, I use an image, divider and paragraph of text to specifically describe six different categories. This wouldn't scale that well. One suggestion would be to have Ben add double decoding to the <$MT$> variables, so that someone could do something like <$MTInclude="<$MTEntryCategory$>.txt"$>. Thoughts, Ben?

Anyways, in my case, the above code was placed into my Individual templates, and this nicely duplicates what I have going on at Gamegrene.com. However, I'd like to do the same thing in my Category Archive templates, and that's where I'm running into some problems.

If I just throw in "Entries category="CategoryName"" six times, then all six pieces of text get thrown out to the screen, causing an ugly mess of laughable proportions. The same thing happens if I use MTArchiveList, with the six MTEntries within. Any thoughts on how I can do this? This is practically the last thing I need to do to get the templates the way I want them.

Help?
btrott
I was just about to suggest using SSI, and then I read your response... so yes, I would definitely recommend SSI in this situation. And if you want to manage those included files through MT, you can always make them index templates.

You're right that double-interpolation of MT tags would solve this in MT itself, but I hesitate to do that, because it will slow things down. If there were a way to indicate that a particular piece of text should be double-interpolated (like the way you put /ee at the end of a Perl substitution if you want the right side to interpolate twice), then I would like it better, because at least the system wouldn't have to always try to interpolate every string to the Nth degree. :)
muta
I'm struggling with the same problem, pretty much, trying to generate a list on each individual archive page of other entries that are in the same category.

What if, instead of double interpolation, you just made <MTArchiveList> a little more context sensitive?

maybe <MTArchiveList archive_type="Category" context="page">?

actually it just occured to me a possible way to do this.. I'll be back smile.gif
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-2009 Invision Power Services, Inc.