Tobias
September 7, 2024, 12:10pm
1
Hi there,
ghost has the handlebars filter {{#unless @member}}
. Is there a way/plugin to use that within the content of a post?
What I want to do
I’d like to add content upgrades to my post only for (free or paid) subscribers. Those content upgrades are at different places within a blog post.
Thus, the Public Preview Card is not sufficient, because I don’t want to put everything at the end of the post. This would just be confusing.
Ideally, I could add some sort of preview or description to non-subscribers.
How this could look like:
What non-subscribers see
What subscribers see
Discover the 7 elements for [something relevant for audience ] Sign up to get access for this part of the content. [Sign-up button]
If you want to truly succeed at [something relevant for audience ], then consider using these 7 techniques: 1. Foo 2. Bar 3. …
Is something like this possible? If so, how?
Thanks in advance for your input :)
You should dive into {{visibility}} at post context.
Hello! @MLFromScratch
Maybe it will be useful to you:
<style>
.premium,
.free {
display: none;
}
.premium.paid,
.free.members {
display: block;
}
</style>
{{#if access}}
{{content}}
{{else}}
<div class="premium {{visibility}}">
<h2>Paying subscribers only</h2>
{{#if @member}}
<p>Upgrade your account</p>
{{else}}
<p>Sign up now and upgrade your account</p>
{{/if}}
</div>
<div class="free {{visibility}}">
<h2>Subscribers only</h2>
<p>Sign up now</p>
</div>
{{/if}}
Tobias
September 7, 2024, 2:57pm
3
Thanks for your quick reply.
Does ghost evaluate handlebars code within a blog post’s content? I wasn’t aware about that. I thought it’s only possible to use handlebars in themes itself.
Raki
September 7, 2024, 5:09pm
4
Does ghost evaluate handlebars code within a blog post’s content?
No, Ghost doesn’t. Whether you use a functional helper or public preview card, free content will be separated from paid content.
To put free content within paid content, you need to use Member API to check the user’s paid status and then dynamically insert free content into paid content.
Tobias
September 8, 2024, 9:09am
5
Thanks for the clarification.
Do you happen to have some resources at hand you could point me to (besides the docs, OFC—cheching them out right now).
It would be a great first start to understand how
the separation of the public preview card, and/or
the sign up card (as it is only shown to “unknown” readers")
works. Unfortunately, I can’t find the relevant code in the github repository.
Raki
September 8, 2024, 5:51pm
6
I’m not sure about the details, but they are related to the content
helper. You might trace it.