D_AL
March 22, 2023, 10:28am
1
Let’s explain, for example we have 4 posts with primary tag HELP.
Article 1 | Tags : Help, Account (where Help is Primary Tag)
Article 2 | Tags : Help, Registration (where Help is Primary Tag)
Article 3 | Tags : Help, Password (where Help is Primary Tag)
Article 4 | Tags : Help, Privacy (where Help is Primary Tag)
Now I created collections mysite/help/ where I have filter in routes.yaml
/help/:
permalink: /help/{slug}/
template: help
data: tag.help
filter: primary_tag: help
On /help/ site I wish to create 4 blocks with posts for each sub category ex. (Account, Registration, Password, Privacy)
I don’t know hot to create foreach to receive 4 blocks of post for each tag.
I would do it differently:
Instead of sourcing the data from the tag, I would create a page.
data: page.help
In the page editor you can assign tags, there you can add the tags to be used for the different sections.
In the help
template, foreach
over the page tags, fetch posts and render them.
2 Likes
D_AL
March 23, 2023, 8:45am
4
In the help
template, foreach
over the page tags, fetch posts and render them.
I;m not able to get tags
{{#foreach tags}}
<a href="{{url}}">{{name}}</a>
{{else}}
<p>There were no tags...</p>
{{/foreach}}
Returns There were no tags…
D_AL
March 24, 2023, 3:14pm
5
Ok i figured it out
Now wondering if its possible to create page as child.
Ex. I have Page 1 and Page 2
To set my Page2 after a slash like: mydomain/page1/page2
D_AL
March 29, 2023, 11:53am
6
I followed your advice and it seems very good.
I created three pages ex. Help, Privacy
I created posts ex. P1 [tags: Help, Account], P2 [tags: Privacy, Account]
Below you can find my page.hbs
template.
I wish to display in section Account only posts for tag=accounts & tag=page.title
So page
Help should display only Post P1 and similar
Privacy should display only Post P2 and similar
{{!< default}}
{{> search-container}}
<div class="gh-main gh-outer" style="background-color: #F4F4F8">
{{#post}}
{{> "main-category-blocks"}}
<div id="featured-faq" class="gh-inner" style="margin-bottom: 65px">
<div class="d-flex flex-wrap" style="gap: 25px;">
{{#foreach tags as | this_tag|}}
<div class="col-12 col-md-5 flex-grow-1">
{{#get "posts" limit="5" include="primary_tag" filter="tags:{{slug}}"}}
{{!-- {{#get "posts" limit="5" include="primary_tag" filter="featured:true+tags:{{slug}}"}} --}}
<div class="topic-feed">
{{#foreach posts}}
{{> faq-featured-question}}
{{/foreach}}
</div>
{{/get}}
<a class="d-flex justify-content-end" style="font-weight: 400; font-size: 12px; line-height: 16px; text-decoration-line: underline; color: #271E87;" href="{{url}}">{{t "Look More"}}</a>
</div>
{{/foreach}}
</div>
</div>
{{/post}}
</div>
1 Like