0

Sometimes I get lost in all the options I have on the drupal platform.

I am currently creating a site for a choir. I want them to be able to add new concerts. There has to be a page for every concert. I want to use a multicolumn layout for those concertpages. This layout I want to define using a twig template. Each concert would get a standard layout at creation.

I want to be able to override that template for each individual concert. Once the grafic design for promotion material is finished the page has to be inline with the grafic design. But it still has to be editable like a normal drupal-page.

I thought about doing that with a content type. But can I theme that in a multicolumn layout using twig? It seems like I only have a {{ content }} variable in twig.

Am I missing something? It seems like a custom entity would be a better solution since I can define a render array and add the fields in different variables wich I can then use in my twig file.

Maybe I got it all wrong, this is my second drupal project and I'm still learning to find the best way of getting things done.

Matt.

2
  • Custom theming stuff like this is usually a road to hell with regards to maintenance and changes over time, just use Display Suite.
    – Jeff Burnz
    Commented Sep 11, 2016 at 10:38
  • Totally. Look at what you can do with display suite and layout plugin before you reach for custom templates. Particularly if you want to be able to override for each concert, as Display suite gives you some UI options for picking layouts and applying classes.
    – Jonathan
    Commented Sep 11, 2016 at 23:26

1 Answer 1

1

Make a copy of node.html.twig and rename the copy to node--[content-type-name].html.twig which goes inside your theme's template folder.

Then in node--[content-type-name].html.twig find and delete {{ content }} and instead in there you put

{{ content.title }} 
{{ content.body }} 
{{ content.field_name }}

This is how you can render your fields individually.

Then, you can wrap them inside an id or class divs. Ex:

<div class="something">{{ content.field_name }}</div>
<div class="something-else">{{ content.field_name_other }}</div>
4
  • man... can't believe it is that simple. But that was my missing link. Can I ask just one more question? If I have a field that consists of multiple values. Can I also loop through those? say I have a field with multiple dates. can I have those rendered individually too?
    – DragonEye
    Commented Sep 10, 2016 at 10:06
  • @DragonEye funny, I just answered that in the newest questions, the one below yours. Anyhow, here is the direct link How To Wrap Multiple Content Field Items In Li Tag
    – No Sssweat
    Commented Sep 10, 2016 at 10:08
  • Keep It Super Simple, right? Commented Dec 15, 2016 at 7:11
  • 1
    @Pierre.Vriens right
    – No Sssweat
    Commented Dec 15, 2016 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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