[SOLVED] Plan image also for the Free Registered Users (without subscriptions)

7 years 5 months ago - 7 years 5 months ago #288169 by liaskas
Well...

The following recipe...
[cb:if cb_userplan!=""][value][cb:else]<img src="images/stories/plan1.png" />[/cb:else][/cb:if]
works partially, as it shows the right plan image for the active paid subscriptions, but it returns the "-" instead of the plan1.png.

Also tried [cb:if cb_userplan!=""][value][cb:else]Plain text here[/cb:else][/cb:if] but i get the "-"


Custom HTML field has no profile value layout parameter.
Do you mean query field?

Please Log in to join the conversation.

7 years 5 months ago #288175 by krileon
Looks like layouts don't work if the field has absolutely no value. In that cause you'll have to use a Custom HTML field for now. Have added a bug ticket to fix for next CB release.

forge.joomlapolis.com/issues/6310

Custom HTML field has no profile value layout parameter.
Do you mean query field?

Custom HTML doesn't need layout parameters as its description is what is directly output, which is where you'd put the following for example.

[cb:if cb_userplan!=""][cb:userfield field="cb_userplan" /][cb:else]<img src="images/stories/plan1.png" />[/cb:else][/cb:if]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 5 months ago #288192 by liaskas
Thank you Kyle.

It worked as a Custom HTML with the following code
[cb:if cb_userplan!=""][cb:userfield field="cb_userplan" /][cb:else]<img src="images/stories/plan1.png" />[/cb:else][/cb:if]

But... (there is always a but to make things harder)

How can we stow different text for each plan?

For example...

No paid membership has no privileges, as it is the free lifetime plan
Plan 2 has some privileges
Plan 3 has full privileges

Can we use something like the following in Custom HTML field? What is the right syntax? I tried the following and it does not work.

[cb:if cb_userplan=""]<img src="images/stories/plan1.png" /> The member has no privileges[/cb:else][/cb:if]
[cb:if cb_userplan="2"][cb:userfield field="cb_userplan" /] Limited privileges[/cb:else][/cb:if]
[cb:if cb_userplan="3"][cb:userfield field="cb_userplan" /] FULL privileges[/cb:else][/cb:if]

Thank you!

Please Log in to join the conversation.

7 years 5 months ago - 7 years 5 months ago #288201 by krileon
That field does not give you a plan ID. It gives you the URL to the plan image. So that's what you have to condition against. This is done easiest by conditioning against the filename of the plan image using a regexp operator. Example as follows.

[cb:if cb_userplan=~"/test\.png/"][cb:userfield field="cb_userplan" /] TEST IMAGE MATCHED[/cb:if]

See the below substitution tutorial for proper substitution usage and syntax.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb

Additionally if you've latest CBSubs build and enable content prepare usage for your Custom HTML field you can use the below usages.

www.joomlapolis.com/news/18550-cbsubs-gpl-4-1-with-timed-content-taxes-inclusive-price-display-and-plan-substitutions-usable-anywhere

CBSubs provides its own condition substitution usage to condition content based off plan status. Example as follows.

[cbsubs:if plan="1" status="A"]PLAN 1 IS ACTIVE[/cbsubs:if]

Note the CBSubs usage does not have ELSEIF or ELSE usages at this time.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 5 months ago #288210 by liaskas
Thank you for all your help Krileon.

It finally worked with
[cb:if cb_userplan=~"/test\.png/"][cb:userfield field="cb_userplan" /] TEST IMAGE MATCHED[/cb:if]
that you suggested.

Issue is solved. Thank you again!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.228 seconds

Facebook Twitter LinkedIn