Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
@KK, is it possible to create 'unnecessary' route_constraints?
I would like to have both options in url for a page_view: /list/company OR /list/company.html
The 'pattern' we use is plain regex, @trendoman.
It should be a simple affair to create a regular expression where ".html" part is considered optional for matching. As an alternative, you may declare two separate routes (one with and another without .html) where both invoke the same snippet.

I think you should go for the first option.
KK wrote: The 'pattern' we use is plain regex, @trendoman.
It should be a simple affair to create a regular expression where ".html" part is considered optional for matching. As an alternative, you may declare two separate routes (one with and another without .html) where both invoke the same snippet.

I think you should go for the first option.


Thank you very much :) inspiring as usual :)
I'm scared of regex, actually. But this is a great opportunity to fight the goliath :D
Another question:

My goal is to match the same page-view for various patterns: 123456789.html, id123456.html (rt_company, rt_format='\.html').

In the first sample, I would like to pass to my filter an argument: filters='company_exists=number', which will search for custom_field number with rt_company as a value. If company is found by its number, then I will set a global variable with it to use later.

In the second sample, I would pass filters='company_exists=page_id', which will help me search for a company by k_page_id.

What's the best strategy to implement this?
Simple solution is to validate by title_ready, and after route is matched go for real validation.
Another simple solution is to add another similar routes with different name and route_constraint.


P.S. Another solution comes to mind is to remove "id" and in filters look for a company first by number, then by id. In this case I am afraid that id could be the same as number by chance.
I have found undocumented tag, ex: <cms:route_values temp='123' /> and wonder, when it can be used?
5 posts Page 1 of 1
cron