I have a #privatenewsletter tag that I use for member-only newsletters. I then use that tag to keep them off the front page in the non-featured section, but still make them available elsewhere for members to read on the web site if they want to.
{{#get “posts” filter=“featured:false + tags:-[hash-privatenewsletter]” as |notfeatured|}}
So, I wanted to also filter them out of the archive page (same reasoning). The pertinent code in the archive page is
I tried putting the same filter statement on the {{foreach}} line, but it didn’t work. I then tried adding a {get “posts” line with the filter. It worked, but broke the pagination.
If I can’t filter them out of the archives page, it’s not a huge deal – but, it would be better if I could. (I’m going to give them their own page.)
Would you be able to share your routes.yaml so we can see your current setup?
It sounds to me like you want to use either channels or collections for your archive page, with a filter on, and then a separate collection for your #privatenewsletter posts.
Hmm … I’ve never totally understood how routes.yaml works. I was able to modify it when I made a custom home page – but the filter that’s there doesn’t work. Stories tagged #privatenewsletter still show up, so I tried adding the filter in the home page code itself.
So, any thoughts on this setup? The home page is working, with the filter in the code. The archive page is working – until I try to filter out the newsletters.
Oh, and I got my newsletters.hbs file built, and changed routes.yaml to point to it. Works as it should – except now the sidebar is under the main content. Ugh.
Still have two problems:
Archive page is including the newsletters, even though the filter in routes.yaml should prevent that.
Newsletter page has the sidebar below the list of newsletters. It’s a direct copy of the archive page, which is working correctly.
Thanks for pointing me in the direction of modifying routes.yaml file. Any further ideas welcome.
I tested your routes.yaml file but I couldn’t recreate the problem . Filters worked as expected and archive, newsletter, and home page rendered with the right posts. Have you tried restarting Ghost?
I asked an earlier question about filtering. Thanks to the people who replied! As a reminder, the goal was to keep our #privatenewsletter posts from appearing on either the home page or the archives page, and only on the Newsletters page.
After making changes to routes.yaml, I got the #privatenewsletter posts off the front page, off the Archives page, and showing up only on the Newsletters page. BUT – the URL for each article on that page is some sort of GUID-like URL, like this:
An update: I have tried various combinations of routes.yaml configurations, and none are working. I did learn from an earlier posting that if a post isn’t assigned a route, Ghose uses the preview URL. which is apparently what is happening to me.
Here’s the current ROUTES.YAML file. Note that with this file in place, I hit two of the three goals: no private newsletters on the home page, and no private newsletters on the Archives page.
(Please don’t open multiple topics about the same thing - makes it hard to keep track of discussions - I’ve merged the other thread into this one)
All posts must exist in a collection in order to have a slug. Currently newsletters don’t exist in any collection, so they don’t have one. It sounds like what you’re trying to accomplish would look like something along the lines of:
I read all the documentation on Routes.YAML that I could find, and nowhere do I remember reading “All posts must exist in a collection in order to have a slug.” That was breaking news to me. Thank you for sharing that; it makes the distinction between routes and collections a little clearer. Thanks again!