Rhys
August 24, 2023, 9:48am
1
Hi all – I have post labels on a customised Tripoli theme as seen here: www.greatcentralgazette.org . It shows whether a post if “Public” or “Member-only”.
This is the code in card.hbs which displays them correctly across the website:
{{#has visibility='paid'}}
<span class='c-card__payment-label'>MEMBER-ONLY</span>
{{else}}
<span class='c-card__payment-label'>PUBLIC</span>
{{/has}}
However, it doesn’t display them correct in the Latest box on the homepage. It displays every post as “public”, even though some are set to paid members only.
If I set the post to member’s only, it displays correctly. But I want it to display correctly when set to paid members only.
Any help/advice?
RyanF
August 30, 2023, 6:42pm
3
Rather than has
, try the match
helper:
{{#match visibility "paid"}}
{{else}}
{{/match}}
Rhys
August 31, 2023, 6:58am
4
No luck, still the same as before.
Are your posts restricted to ‘paid members’, or to a specific tier? I ask, because there’s some buggy behavior around tiers and #get requests that might be at work here. #get helper retrieve pages or posts correctly with tier restrictions · Issue #16250 · TryGhost/Ghost · GitHub
Rhys
August 31, 2023, 6:29pm
6
They are set to “paid members” only.
“Members only” displays the members-only label correctly.
“Paid members” and specific tiers do not.
This will be included in the next Tripoli version. It’s a bit tricky as there is more than one scenario to it, but here is how I do it.
{{#if @site.members_enabled}}
<div class='c-visibility-label
c-visibility-label--{{ visibility }}
{{#if @member.paid}}
c-visibility-label--is-paid-member
{{else if @member}}
c-visibility-label--is-member
{{/if}}'>
<span class='paid'>{{t 'Paid' }}</span>
<span class='members'>{{t 'Members' }}</span>
<span class='public'>{{t 'Public' }}</span>
</div>
{{/if}}
.c-visibility-label span {
display: none;
}
.c-visibility-label--paid .paid,
.c-visibility-label--tiers .paid,
.c-visibility-label--members .members,
.c-visibility-label--public .public {
display: block;
}
.c-visibility-label--is-member.c-visibility-label--public,
.c-visibility-label--is-member.c-visibility-label--members {
display: none;
}
.c-visibility-label--is-paid-member {
display: none;
}
1 Like
Rhys
September 6, 2023, 11:53am
8
That’s good! Looking forward to the next version. Did you create a new file for this or place it in card.hbs?
Yes, a new partial file to include it in different places such as the top sidebar or the regular cards.
Rhys
September 7, 2023, 7:11pm
10
Created a new partial, but it doesn’t display them correctly. What’s your setup look like?
We will go through another topic integrating this into the theme, so, please wait for it and you will get a full update soon :)