EXT: CoolURI

Extension Key: cooluri

Copyright 2000-2002, Jan Bednařík, <info@bednarik.org>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.com

Table of Contents

EXT: CoolURI	1

Introduction	1

What does it do?	1

URI Transformer	1

Requirements	1

Users manual	1

Multidomain support	2

Migrating from RealURL	2

New stuff that's not yet in the manual	2

maxsegments	2

FAQ	2

To-Do list	2

Introduction

What does it do?

Everybody know extension RealURL. Well, this is an alternative. It should solve all RealURL problems and add something new. Basically, RealURL's configuration voodoo is substituted by XML configuration file, which is kept as easy to understand as possible.

URI Transformer

The main part of the extension is not related to Typo3 at all. It's a solo project for transforming URIs. Before I create a web about it, you can download manual for it on http://download.bednarik.org/URITransformer.pdf. Since the whole project was my diploma thesis, the manual contents some useless stuff. The real manual starts on page 19. There you can find description of the XML configuration file.

Requirements

- PHP 5+ with SimpleXML enabled!

MySQL 4.1+

Additional Information

For more information read the tutorial from Adreas Becker: http://docs.google.com/View?docid=dd33gg45_3f8j96p

Users manual

- Default configuration file is placed in EXT:cooluri/coouri/CoolUriConf.xml_default. You have to copy it somewhere, remove “_default” from the extension and specify path to it in the extension's setup.

- Use the same .htaccess as you'd with the RealURL (that means, redirect everything to index.php):

RewriteEngine On

RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)$ - [L]

RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/.*$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php

Add this to your template:

config.baseURL = http://www.example.com/

config.tx_cooluri_enable = 1

config.redirectOldLinksToNew = 1 # if you want to redirect index.php?id=X to a new URI

Multidomain support

If you have more domains in one page tree, make sure to check the option in ext. setup. And then you have to specify domain for EVERY rootlevel page!

Migrating from RealURL

The field Speaking URL path segment (tx_realurl_pathsegment) is kept with its values, but make sure it's listed in the <title> element.

Installing CoolURI with DBAL extension

Everything is fine now.

New stuff that's not yet in the manual

maxsegments

You can limit number of segment in pagepath using element maxsegments – subelement of pagepath element.

<pagepath>

<title>tx_realurl_pathsegment, alias,subtitle,title</title>

<saveto>id</saveto>

<default>0</default>

<userfunc>tx_cooluri->getPageTitle</userfunc>

<maxsegments>1</maxsegments>

</pagepath>

disabling page title processing

If you need a page title to stay exact the same as you have set it, you need to suppress the default page title processing from non-url-like form to url-like (I call this urlizing). To do this, you need to set subelement of the pagepath element urlize to 0.

<pagepath>

....

<urlize>0</urlize>

</pagepath>

FAQ

Q: How to change order of fields from which a title is retrieved?

A: Order is set in element title. Default order is: <title>alias,subtitle,title</title>

Q: How to set a translation?

A: You need to add a subelement <part> to element <uriparts>. Most rewriting is from "param[key]=value" to "somecoolvalue". Where the rewriting looks for "somecoolvalue" in the database:

<part>

<parameter>param[key]</parameter>

<lookindb>

<to>SELECT title FROM table WHERE uid=$1</to>

<urlize>1</urlize>

</lookindb>

</part>

Q: Value isn't translated OK. Instead of national characters I get dashes.

A: The problem is with Debian server, that doesn't support iconv translit conversion very well. The way to fix this is replace all occurences of <urlize>1</urlize> to <sanitize>1</sanitize> in the XML configuration.

A2: Instead of sanitize use <t3conv>1</t3conv> at the same places sanitize would be used. And place it into the pagepath element as well.

Q: I get PHP error after installing CoolURI extension

A: Please, make sure, you meet all requirements (see above).

Q: tt_news doesn't display right

A: The cache parameter cHash is removed from URI in the default configuration. However, this causes tt_news (and other extensions) not to change its contents and display still the same. You have to either allow the ugly cHash parameter or make an extension COA_INT (may lower performance).

Q: How to migrate from simulateStaticDocuments to CoolUri

A: You need to update your rewrite rules.

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l

RewriteRule ^/.+\.(.+)\.[0-9]\.html /index.php?id=$1 [R=301,L,QSA,NE]

Here's description from Peter Bücker:

First of all, the left hand side obviously matches the URL format generated by SSD. The right hand side redirects all requests to /index.php with the id extracted from the request. It does this externally, with a HTTP 301 (permanently moved), so that users start using the new URLs. Of course, this is the last rule to be evaluated (L). In combination with "config.redirectOldLinksToNew = 1", this is really nice :-)

Furthermore, QSA tells Apache to append all query strings originally found in the request URI to /index.php?id=$1. Without QSA, those query strings would be discarded. NE stands for "no escape", which means that characters like '[' won't be replaced by their percent-coded counterparts. I didn't do further research, but without NE, plugin parameters break.

Also note that the 4 mod_rewrite directives have to be placed just above the usual RewriteCond... RewriteRule .* /index.php stuff. So in effect, for httpd.conf, it will look like this:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l

RewriteRule ^/.+\.(.+)\.[0-9]\.html /index.php?id=$1 [R=301,L,QSA,NE]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l

RewriteRule .* /index.php

Q: CoolUri doesn't work in ISS with ISAPI

A: Try to add this line to localconf.php. Or set this value using the install tool:

$TYPO3_CONF_VARS['SYS']['requestURIvar'] = '_SERVER|HTTP_X_REWRITE_URL';

Q: How to mix pagepath with other parameters

A: First you need to map parts of pagepath on parameters:

<part pagepath="1">

<parameter>p1</parameter>

</part>

<part pagepath="1">

<parameter>p2</parameter>

</part>

<part pagepath="1">

<parameter>p3</parameter>

</part>

<part pagepath="1">

<parameter>p4</parameter>

</part>

this will map 4 parts of a pagepath to parameters p1 – p4.

Then you need to insert these parameters into paramorder:

<paramorder>

<param>p1</param>

<param>L</param>

<param>p3</param>

<param>p2</param>

</paramorder>

this will produce URL like: firstlevel/english/thirdlevel/secondlevel.

Q: I've got multilanguage tt_news and it doesn't work just right

A: Try this setup:

<part>
<parameter>tx_ttnews[tt_news]</parameter>
<lookindb>
<to>SELECT title FROM tt_news WHERE (uid=$1 or l18n_parent=$1) AND sys_language_uid={L=0}</to>
<t3conv>1</t3conv>
</lookindb>
</part>

To-Do list

Support

You can support future development of this extension by donations. You can use my PayPal account (go to http://www.bednarik.org and there's a PayPal icon you can click to send money).

Contact

You can use direct e-mail contact if you believe, that you have found a bug. If you just simply don't know, how to set transformation rules, please ask in the English mailing list. To make sure, I'll read your message there, put “cooluri” keyword into your subject.

EXT: CoolURI - 4

EXT: CoolURI

Kasper Skårhøj

2002-11-01T00:32:00

Jan Bednarik

Kasper Skårhøj