[Catalyst] regexes and auto actions

Ash Berlin ash at cpan.org
Tue Oct 31 20:38:16 GMT 2006


Carl Johnstone wrote:
> Hi,
> 
> Got a question regarding the best way of setting up handlers.
> 
> 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.
> 
> Anybody got a neater way of doing it?
> 
> Thanks
> 
> Carl
> 

Use a controller base class that implements the story/comments actions, 
and just set the relevant section (i.e. news, sport, football) in an 
auto or a begin action.

Make sense?

Ash



More information about the Catalyst mailing list