Help - Search - Members - Calendar
Full Version: Categories and templates
Movable Type Community Forum > Additional Resources > Tips and Tricks
mOdEtWo
I'm trying to build my whole site in mt. So far so good - but there's something I don't understand.

I have a news category/page, and an announcement category/page. Let's say I want to tell the visitors about a party; I write the entry, and add the category News, and Announcement as 2.nd category. I rebuild my site, and the party info is displayed on both the announcement page, and the news page. BUT: All other news elements (which are added to the category news only) is also displayed at the announcement page - which I don't want it to.

So, how do I add elements to the different pages, depending on what category the elements are added to!?

Thanks for a great weblog program!
kadyellebee
You might double check your Category Archive template to make sure that the MTEntries container doesn't have a category name specified in it. it should just be
CODE
<MTEntries>
and the the category archiving process will fill in one category for each page.

If that doesn't help, maybe a link to your site would help us.

Kristine
mOdEtWo
I don't understand. The :MTEntries: is what you said it should be. I've created one news template, and one arrangement template - but where do I specify what template that should contain what data/category?

I'm sure I'm missing something here... ohmy.gif
rayners
Are you trying to have different templates for different categories?

There's no real automatic way to do that at the moment. You can do it manually with two different index templates.
mOdEtWo
QUOTE (rayners @ Jun 5 2003, 11:58 PM)
Are you trying to have different templates for different categories?

Well, it seems that the blog adds all elements (posts) to the news.html and the arrangements.html, no mather what catetgory I made the element/post in.

When I add a post to the news category, I want it to be added to news.html - and when I add a post to the arrangement category, I want it to be added to arrangements.html, and not both.

But, if I add the post to the news AND the arrangements category, I want it to be displayed at both news.html and arrangement.html.

Sorry if I was unclear in the other posts.
girlie
What you're describing is the default behavior for Category Archives.

You don't need to create special templates for each category, just use the default Category Archive Template that already exists, and make sure you check Category Archives in Blog Configuration | Archiving.

MT will create a category page for news with only entries in that category, and a category page for arrangements with only entries in that category; and any entries posted to both categories will appear on both pages.

But if you want to create new Index Templates with each showing only one category, you need to specify the category in the MTEntries tag in each template:

CODE
<MTEntries category="news">

<MTEntries category="arrangements">
mOdEtWo
QUOTE (girlie @ Jun 6 2003, 02:04 AM)
CODE
<MTEntries category="news">
<MTEntries category="arrangements">

Yay! That was what I needed, thanks a lot!

biggrin.gif
schyzo.freak
QUOTE (rayners @ Jun 5 2003, 09:58 PM)
Are you trying to have different templates for different categories?

There's no real automatic way to do that at the moment.  You can do it manually with two different index templates.

And how do I do that, rayners? (or anyone that can help me)

If I want each category archive page to have a different layout, how will I link it right in the main index page? And how will I make the the category knows "you, this template is yours, not that one"

I'm having a hard time with the Categories codes smile.gif
markpasc
You really want to be using a Category Archive template--all the linking stuff is handled automatically that way. Unfortunately that makes them all use the same Category Archive template.

Having not actually done this, if you really want entirely different templates for each category, I would try putting the individual templates in template modules named after each category, then using stepan's IncludePlus plugin in the Category Archive template:

CODE
<MTIncludeModule><$MTCategoryLabel$></MTIncludeModule>

You could use the same technique to include only the parts of the templates that are different, too. Maybe someone knows a better way though.
schyzo.freak
Thank you marckpasc, I'll try this!
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.