Typo3: CoolURI and Calendar Base

Meanwhile, CoolURI and Calendar Base are two of the most favorite extensions in the Typo3 extension repository. CoolURI is (beside RealURL) a mature extension for generating user and search engine friendly urls. Calendar Base is a very enhanced extension to integrate calendar functionality on a typo3-based website.

However, CoolURI does not support url preparation for urls generated by the calendar base extension out of the box. To enable this for a Typo3-based website you have to edit your CoolUriConf.xml configuration file. The required modifications teaches CoolURI how to translate the calendar base specific query parameters of your url into a nice url segments.
For example, there is a parameter “…html?tx_cal_controller[uid]=12” and we want CoolURI to integrate the title of the event with the uid 12 into the url itself such as “…/my-event-title.html”. Below, you will find much more parameters that need to be treaten.

Generally, there are two major sections (uriparts and predefinedparts) in your CoolURI configuration XML file you can use to tell CoolURI how to handle parameters:

...
<uriparts>
....
</uriparts>

<predefinedparts>
....
</predefinedparts>
...

“uriparts” are about query parameters that should be integrated in the nice looking url if they are present in the original url.
“predefinedparts” are about query parameters that should not be integrated in the nice url if they are present in the original url.
All query parameters in the original url that are not specified in one of these sections but present in the original url will be kept as query parameters in the nice looking url as well because CoolURI does not know how to handle them. This is also the reason why calendar base query parameters are not handled by CoolURI out of the box.

So let’s move on.

There are two parameters that we will not simply move from query parameters to url parts: the internal id of the event category and the internal id of the event itself. Those two parameters are defined as parts used for a lookup of the corresponding titles in the database:


<part>
<parameter>tx_cal_controller[category]</parameter>
<lookindb>
<to>SELECT title FROM tx_cal_category WHERE uid=$1</to>
<translatetoif>
<match>^[0-9]+$</match>
</translatetoif>
<urlize>1</urlize>
</lookindb>
</part>
<part>
<parameter>tx_cal_controller[uid]</parameter>
<lookindb>
<to>SELECT title FROM tx_cal_event WHERE uid=$1</to>
<translatetoif>
<match>^[0-9]+$</match>
</translatetoif>
<urlize>1</urlize>
</lookindb>
</part>

While we want them to be present in the nice looking url, we should place those two parts in the uriparts section.

All the other calendar base specific parameters are simply defined to be treaten and either ignored or moved inside the url. The following code snippets show the part definitions that can be placed either in the uriparts or in the predefinedparts section. But you should keep in mind, that the resulting nice url should still be able to uniquely identify url event page. So for example, if it might happen that there are multiple events with the same title make sure, that you include parts for the date (year, month, day) inside the uriparts section. If there might be events with the same name at the same date, you might need to include other parameters inside the uriparts section as well.


<part>
<parameter>tx_cal_controller[year]</parameter>
</part>
<part>
<parameter>tx_cal_controller[month]</parameter>
</part>
<part>
<parameter>tx_cal_controller[day]</parameter>
</part>
<part>
<parameter>tx_cal_controller[lastview]</parameter>
</part>
<part>
<parameter>tx_cal_controller[page_id]</parameter>
</part>
<part>
<parameter>tx_cal_controller[view]</parameter>
</part>
<part>
<parameter>tx_cal_controller[getdate]</parameter>
</part>
<part>
<parameter>tx_cal_controller[preview]</parameter>
</part>
<part>
<parameter>tx_cal_controller[type]</parameter>
</part>
<part>
<parameter>tx_cal_controller[gettime]</parameter>
</part>

Example Configuration
If you are not surehow to start in your specific case, you can move one with a common configuration we use in most cases:

Add the following lines at the end of you uriparts section:


...
<part>
<parameter>tx_cal_controller[category]</parameter>
<lookindb>
<to>SELECT title FROM tx_cal_category WHERE uid=$1</to>
<translatetoif>
<match>^[0-9]+$</match>
</translatetoif>
<urlize>1</urlize>
</lookindb>
</part>
<part>
<parameter>tx_cal_controller[uid]</parameter>
<lookindb>
<to>SELECT title FROM tx_cal_event WHERE uid=$1</to>
<translatetoif>
<match>^[0-9]+$</match>
</translatetoif>
<urlize>1</urlize>
</lookindb>
</part>
<part>
<parameter>tx_cal_controller[year]</parameter>
</part>
<part>
<parameter>tx_cal_controller[month]</parameter>
</part>
<part>
<parameter>tx_cal_controller[day]</parameter>
</part>

</uriparts>

And add the following code at the end of your predefinedparts section:


...
<part>
<parameter>tx_cal_controller[lastview]</parameter>
</part>
<part>
<parameter>tx_cal_controller[page_id]</parameter>
</part>
<part>
<parameter>tx_cal_controller[view]</parameter>
</part>
<part>
<parameter>tx_cal_controller[getdate]</parameter>
</part>
<part>
<parameter>tx_cal_controller[preview]</parameter>
</part>
<part>
<parameter>tx_cal_controller[type]</parameter>
</part>
<part>
<parameter>tx_cal_controller[gettime]</parameter>
</part>
</predefinedparts>

Note
Depending on your current configuration, you might need to specify the part order at the end of your CoolURI configuration file. If it is not present yet, try to add the following lines before the ending </cooluri>


<partorder>
<part>pagepath</part>
<part>uriparts</part>
<part>predefinedparts</part>
<part>valuemaps</part>
</partorder>

Leave a Comment