blog.Resource
Sponsors
hosted by punkt.de
sourceforge.net
sunsite.dk
01.09.07 11:39 Age: 1 yrs

Categorization in TYPO3

Category: Søren Andersen

By: Søren Andersen

The subject of categorization in TYPO3 has puzzled my mind countless times. The problem with making your own categorization is, that you disable alle the build-in content elements because your categories are on 1 page only.

For both www.mange-gode-raad.dk (MGR) and www.mange-gode-opskrifter.dk (MGO), I needed categorization. For MGR you could say it was a bit easier, because I didn't need the possibility to categorize one element to multiple categories. This means that the good old page tree is sufficient. For MGO I need one element (one page) to go into multiple categories. So how do you solve that?

First, let's talk about why you would even want to structure your content in: normal (text) pages, category page and element (e.g. a recipe) page. The reason for doing this is simple: It let's you hold on to the flexibility that TYPO3 is known for. If you had a plugin that served your categories from only one page in the page-tree, you would have a problem adding specific text and images to a single category, unless you coded that amount of flexibility into your extension. But why do that, when TYPO3 allready has those features?

SEO was also one of my reasons. Since individual page titlen, meta tags and URL are key components to succesful SEO, I wanted to have control of the individual pages. And this solutions allows me to do just that.

Another obvious reason (atleast for me) was, that it not only allows me to create specific text and imagery for both individual categories or individual elements. It also gives me the possibilities of using existing plugins for functionality like Tip-a-friend, pagecomments, rating, banner administration, and so on. This is one of the main reason for me to create the structure like this. But how do you accomplish this then?

The obvious move would be to check for current extensions, that are capable of doing this. But I didn't find any extensions that did categorization the way i wanted it to be done. But you can actually do this without even installing any extension. The key to doing that, is by using the layout field of the page. The first step could be to rename them from "Normal, layout 1, layout2" to something with a little more meaning. This is done in the TSconfig field of the root page, by this:
TCEFORM.pages {
  layout.altLabels.2 = Category
  layout.altLabels.1 = Element
  layout.altLabels.0 = Regular
}

By doing this, your pages are identified as either being a regular page, an element or a category. You are then free to use conditions in your template, that distinguish the layout from these three types. You do that like this:
[globalVar = TSFE:page|layout = 0]
temp.content < styles.content.get
[global]
(The TemplateVoila would just have to map another template for use on these pages)

I will talk a lot more about www.mange-gode-links-dk (MGL) in the future, because I have planned an extension that I'll release to the TER, building on the lib/div framework. Since I don't know much about OO-programming, I'll have a lot to learn. Furthermore I have decided not to use the layout field for distinguishing the pages. Instead I will make separate doktype for each type (textpage, categorypage, detailed linkview page). Doing this, takes flexibility even further, as I'm not only allowed to make one layout for each pagetype, but not an infinite amount of layouts. (This is also one of the things TemplateVoila could do for you). Since other extensions use doktypes, I decided to make my extension work with any doktype of your choice, with a default of 25.

But how about rendering of these categories and elements? Well unfortunately, the extension I made for rendering was solely minded on MGR and MGO (AND i fucked up with the extension key :)) But the key to rendering the elements is making queries based on the layout value or doktype value, that has been chosen for the kind of page you want to output.

The goes for making toplists, as I have on both MGR and MGO. The queries are made to the table "pages" with the condition that layout should be 1 (or whatever you choose).

This was a rather long post, but an important concept for my projects. Give me your thoughts about it, as I would like to discuss this further.


comments

No comments yet. Be the first to comment on this!

Sorry, comments are closed for this post.