1

I have a structure section. For that section, I have some categories. Each entry has a field where I can select the category that entry belongs to.

How do I include the category uri? For example, "section/category/entry".

4

In the CP, in the settings window for 'categories' you can set whether 'Categories in this group have their own URLs', and define the 'Category URL Formats' for categories and subcategories, and choose a category template. You could use {slug} for example, to route to the index page of the category (or whatever you want to use it for). Of course, you may not need this at all if you don't plan on having a landing or index page for the category.

For getting to an actual entry you would need to set a custom route in the CP using tokens. You could create category/slug for example (where 'category' is your category name, and 'slug' is a token) which would point to your _categoryentry.html template. Any tokens you define will be variables available in your template that you can use to retrieve the appropriate entry.

If your entries will always only belong to one and only one category, then you may consider using the structure itself (i.e. inserting the categories into the structure itself as another level), which will provide the uri you are looking for automatically.

For more information, see the documentation on routing, and categories.

  • I think in my case then, maybe I am looking to use categories in the wrong manner. My entries will belong to one category so using the structure makes sense. But I am still confused as to when to use categories versus a structure. – user3818623 Oct 29 '14 at 3:08
  • You might choose to use a category when you want an item (like an article, project, or product) to show up in more than one section. You can then simply assign the relevant categories to the items, and have them show up where you want them. The downside is that when you go to the item, the uri will not include the category by default without some extra configuration. But the uri /projects/project-name is fine for most cases, and there are workarounds to get '/category/project-name'. – Douglas McDonald Oct 29 '14 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.