Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add Blog Categories with overview per category #113

Open
henkvalk opened this issue May 23, 2024 · 4 comments
Open

How to add Blog Categories with overview per category #113

henkvalk opened this issue May 23, 2024 · 4 comments

Comments

@henkvalk
Copy link
Contributor

Hi there,

We want to add a Blog for a Client. But we want to figure out how to add the categories for the blog.

The following questions I have to figure out :

  • What is the best way to create a blog with categories?
  • Is it possible to create a breadcrumbs like blog/blogpost_category_name/post_name

Can we use the tag for the category? and how do we create an overview page based on a type and tag?

@JeroenBoersma
Copy link
Contributor

routing can be multi-level, but not within the same content type...

so blogpost/specific-contenttype/uid is possible but this should mean that you introduce many content types (for each category/tag)

so, basically it's always uid at the end and a path with slashes allowed (so path/path) in front of it matching to one content type.

you can of coarse solve this by adding the tag to the uid...

/blog/blogpost_category_name-post_name which will work just fine, that way it becomes a clear part of the url.

For FAQ we do more or less the same, every faq item itself is unique, but it has a overlaying category which we use on the index page to group them together...

So the content type has:

  • uid
  • group (which is actually a link to a content type "faq-group" so you get the freedom of adding more later and re-use them easily)
  • Title
  • Content (via slices)
  • and meta data of coarse

on the overview page you group by group and render items underneath.

But for now it is not possible without creating many content types for the same content.
Which is also not much more work at the prismic end, just more work on the content end, because if you want change a content type in prismic for a existing document is impossible.

Hope it helps!


a more difficult approach would be extending \Elgentos\PrismicIO\Controller\Router::match but I don't know how that should look.


For most if not all sites we use the canonical approach that one document should life on just one url and thereby that a blog itself has a unique url and a category or tag is just a grouping factor which you of coarse can use in prismicio_route_index pages to filter on specific tags/category items, which is easier to fix.

@henkvalk
Copy link
Contributor Author

henkvalk commented Jun 7, 2024

Thanks @JeroenBoersma for your explanation and sharing the idea.

So when you add a document link to the 'blog_post', you can also link back to the blog_category to create the breadcrumb path and show other posts from the same category in a sidebar or whatever.

Thanks for the insights

@JeroenBoersma
Copy link
Contributor

Yes you can implement it that way!

@JeroenBoersma
Copy link
Contributor

Take a look at \Elgentos\PrismicIO\Block\Wrapper which can be used for breadcrumbs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants