-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Get helper to fetch featured posts, else block not executing #8747
Comments
Hi @astab, this behaviour deliberately changed between 0.11.x and 1.0. The way this worked in 0.11.0 was confusing, because the Unfortunately, this has been missed in our changelog for 1.0.0 and other documentation. I'm in the process of updating that now and have added a new section to the docs. Hopefully this gets you on your way! Closing this as we're tracking outstanding documentation tasks to wrap up 1.0.0 |
Hi @ErisDS,
|
@astab in this case you should be able to use an explicit {{#get "posts" filter="featured:true" limit="5" as |featured_posts|}}
{{#if featured_posts}}
<h2>Featured posts</h2>
<ul>
{{#foreach featured_posts}}
<li>
<a href="{{url}}">{{title}}</a>
</li>
{{/foreach}}
</ul>
{{/if}}
{{/get}} |
Thank you, @kevinansfield. That solves my problem. |
@astab totally get where you're coming from. @kevinansfield's answer is correct and it is also possible to do things like:
So, whilst the old way this worked was more convenient in a certain sense, I don't think we have added any limitations here, only improved consistency as these same patterns are required when you're not using the |
I'm using the get helper to output a featured posts carousel. If there are no featured posts, blog cover image should be displayed instead. It was working fine with Ghost 0.11.x version, but with Ghost 1.0 the else block is not executing even though there are no posts marked as featured.
Here is my code:
Technical details:
The text was updated successfully, but these errors were encountered: