Cannot apply data in custom template

Hi there.

Im trying to retrieve certain posts in an specific template.

My routes.yaml looks like this:

routes:
  /tos/:
    data: page.tos
    template: tos
  /privacy/:
    data: page.privacy
    template: privacy
  /about/:
    data: page.about
    template: about
  /influence/:
    template: case-studies
    data: tag.casestudies

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

And im trying to call the information in my template like this:

{{#tag}}
{{#foreach "posts"}}
<section class="case-studies-posts">
    <h1 style="color:black">{{title}}</h1>
    {{content}}
</section>
{{/foreach}}
{{/tag}}

The template itself is being display but not the content.

The templates with the data.page works fine.

Any suggestions?

Thank you!

Done!
Solved it with controllers

1 Like

Nice one @tomasyaya! Don’t suppose you can share an example of your routes file for the community to learn from? :slight_smile:

No problem.

This is my Route file, where I use controllers for specific posts in pages.

routes:
  /tos/:
    data: page.tos
    template: tos
  /privacy/:
    data: page.privacy
    template: privacy
  /about/:
    data: page.about
    template: custom-page
  /sponsors/:
    data: page.sponsors
    template: custom-page
  /partners/:
    template: case-studies
    controller: channel
    filter: tag:casestudies
  /thought-leadership/:
    template: though-leadership
    controller: channel
    filter: tag:thought-leadership
  /influence/:
    template: influencer-marketing
    controller: channel
    filter: tag:influencer-marketing

collections:
  /case-study/:
    permalink: /case-study/{slug}/
    filter: tag:casestudies
    data: tag.casestudies
    template: case-post
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/
1 Like

Great, thanks for this! Don’t suppose you can fix the formatting? Looks like they the forum editor broke the indentation :woozy_face:

@DavidDarnes there you go, much nicer

1 Like

Lovely, thank you