I am trying to give 2 content types the same singular slug in bolt. both of them should have the same fields, and the same template. at this point i use the record_template:
tag to set the default template for each content type.
vervolgpagina:
name: vervolgpagina
singular_slug: graszoden
singular_name: vervolg
fields:
titel:
type: text
class: large
group: Content
slug:
type: slug
uses: titel
group: Content
body:
type: html
height: 500px
group: Content
meta_keywords:
type: text
group: SEO
label: "Meta keywords"
meta_description:
type: textarea
height: 50px
group: SEO
label: "Meta description"
record_template: vervolgpagina.twig
graszoden:
name: graszoden
singular_slug: graszoden
singular_name: gras
fields:
titel:
type: text
class: large
group: Content
slug:
type: slug
uses: titel
group: Content
body:
type: html
height: 500px
group: Content
meta_keywords:
type: text
group: SEO
label: "Meta keywords"
meta_description:
type: textarea
height: 50px
group: SEO
label: "Meta description"
record_template: vervolgpagina.twig
so if i just put in one of the two content types and add a page to it then it
redirects me to /graszoden/vervolgpagina
so if i add the secont content type and add another page to it /graszoden/randomexample
what happends now. is that the page that worked just fine. says ERROR 404, and the other page gives me an bolt error with “No listing.twig file specified.”
is there a way to show a content type twice in the cms with other names? Or is there a way to give two content types the same singular slug?
Thanx in advance,
2
Answers
After some more projects in bolt using twig ive got some other solution.
If you want to use singular slugs multiple times u are forced to create a listing page. But with this you will not have to. Just create an local extension and fill in the part highlighted at the end in this answer.
Link to sourcecode No readme yet. But I hope the explanation here is good enough.
Here is the extension file code (This code is litteraly all the functionality, you will have to create a local extension for this to work ):
Becouse this is an new starting project. The only thing that is variable is this part
This particular piece of code is where u fill in the singular slug u want to use. It can contain infinite slugs
Hope this helps someone else later on. Happy coding!
No, you can’t. If you have two contenttypes with the same slug and same fields, it should really just be one CT.
Perhaps what you might want is a “Grouping Taxonomy”, see the example in taxonomy.yml for that.