docs icon indicating copy to clipboard operation
docs copied to clipboard

Collections: Add more examples and detailed explanation for collection routing

Open dadaxr opened this issue 2 years ago • 0 comments

This PR tried to achieve 2 goals :

  • insist more on the fact that we can use, not only meta variable in collection routes but also, fields defined in the blueprint
  • suggest that for advanced stuff we can also use field using computed values.

Why ? because I had this project with a "products" collection and a "categories" collection (each product belonging to a category). For SEO purpose, product url was supposed to be "/category_url/product_slug" or even "/master_category/child_category/product_slug" (when using nested categories) .

I had hard time figuring out how to achieve that while reading the doc carefully.

I first attempted to recreate custom routes, but it was quite complicated and implied a lot of side effects (like product urls not included in seo-pro sitemap ...)

then I tried to use Antlers in my routes :

route: "{{ category.url() }}/{{ slug }}"

But it triggers an error, so my last attempt was to use that computed values, and it worked beautifully (without side effects).

dadaxr avatar Sep 25 '23 05:09 dadaxr