Go to content Go to sidebar

Migrating to TextPattern: Default Section PermaLinks

Now that the server understands our default section url, I need to generate matching permalinks for my TextPattern installation. This is just a bit tricky – the standard txp:permlink tag is handled by the doPermlink routine in publish.php not the standard TextPattern parse routine. As best as I can tell, parse doesn't like nested tags and the standard

<txp:permlink><txp:title /></txp:permlink>

idiom requires special handling. I handle this by making the title the default permalink anchor text, with an attribute to specify an alternate.

Here is the idx_defaultSection plugin for TextPattern. In clean-url mode, it generates a default-section permalink when viewing a default-section page. And it appends an s=section parameter to all messy-urls. It accepts two attributes:

defaultSection
The name that should be used in TextPattern clean-url mode to specify the default section. Index.php will be used if this attribute is not specified. However, default section awareness is not retained when following a index.php permalink.
urlText
The anchor text that is wrapped in the permalink. If this is not supplied, then the article title will be used.

Part 3: Recent Articles Tag.