[Catalyst] regexes and auto actions
Carl Johnstone
catalyst at fadetoblack.me.uk
Mon Nov 13 10:19:33 GMT 2006
Hi,
I posted this a couple of weeks ago.
> The site is split into many areas (and subareas) defined by URL path, the
> same types of content appear in each area of the site.
>
> There's stuff that needs setting up that's specific to the area of the
> site, this appears around the main part of the content of the page and
> includes stuff like latest articles for that area.
>
> At the same time the actual appearance of the article within the template
> is always the same, so we don't want to duplicate all the code every time
> we're dealing with a standard article.
>
> So we have:
>
> /news/
> /news/story/1
> /news/comments/1
> /sport/
> /sport/story/2
> /sport/comments/2
> /sport/football/
> /sport/football/story/3
> /sport/football/comments/3
>
> etc
>
> Our plan was to use auto actions in the various Controllers to define all
> the area specific stuff. Then use a Regex action in another Controller to
> actually generate the article.
>
> In practice however only /article/auto and /auto get called.
>
> Any other solution we've come up with has involved adding a story action
> in every Controller. This will be a drag as for each new type of content
> we'll need to add an action in every controller.
After some experimentation we've done it by subclassing.
We've defined a article controller with a story/(\d+) LocalRegex action,
"comments" action and a default index action. Then used this as the base
class for our news, sport, football, etc Controllers. We can then override
where the index page is a different style etc.
Carl
More information about the Catalyst
mailing list