Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] CB substitution usage...

11 years 8 months ago - 11 years 8 months ago #220957 by opensaucesystems
[SOLVED] CB substitution usage... was created by opensaucesystems
I'm loving finding out about CB substitutions, but am stumped.

I have a field delimiter that shows a button depending on another field as shown below:
Code:
[cb:if user="#me" cb_userprofilelevel="member"]<form method="post" action="/somewhere"><button class="button">Go</button></form>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member"]<form method="post" action=""><button disabled class="button">Go</button></form>[/cb:if]
This works and adds the button depending on the field cb_userprofilelevel.

What I need is to not show this button if the current logged in user is viewing their own profile.

I have tried the following code, but no button is displayed on any profile:
Code:
[cb:if user="#me" cb_userprofilelevel="member" AND user_id!="myid"]<form method="post" action="/somewhere"><button class="button">Go</button></form>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member" AND user_id!="myid"]<form method="post" action=""><button disabled class="button">Go</button></form>[/cb:if]
Also, why doesn't this work:
Code:
[cb:if user="#me" cb_userprofilelevel!="member" AND user="#displayed" cb_userprofilelevel="member"]<form method="post" action=""><button disabled class="button">Go</button></form>[/cb:if]
What am I doing wrong?
Last edit: 11 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220984 by krileon
Replied by krileon on topic CB substitution usage...
The below should work.

and user_id!="myid"

or

&& user_id!="myid"

Both will do an "and" statement and am pretty sure it's case sensitive.


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 or Create an account to join the conversation.

11 years 8 months ago #221015 by opensaucesystems
Replied by opensaucesystems on topic CB substitution usage...
I have tried both your suggestions, but nothing shows on any profile or list.

In fact I am unable to get any "and" statment to work, could you give me a known working statement to try so I can see if it's my end.

I'm using CB 1.9

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #221050 by krileon
Replied by krileon on topic CB substitution usage...
You have user="#me". So user_id will always equal myid. Remove that and it should work fine. Substitutions on profile always use the user being displayed unless set otherwise (as you've done).


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 or Create an account to join the conversation.

11 years 8 months ago #221084 by opensaucesystems
Replied by opensaucesystems on topic CB substitution usage...
I wanted to have two buttons that displayed on the user list: one to message the user and another to link to the user profile.

This is the field delimiter code that I tried using CB Substitutions only:
Code:
[cb:if user="#me" cb_userprofilelevel="member" and user="#displayed" user_id!="myid"]<div id="contactMember[user_id]" class="contactMember"><form method="post" action="/messages?option=com_uddeim&task=new&recip=[user_id]&nouserlist=7"><button class="button">Contact member</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member"]<div id="contactMember[user_id]" class="contactMember"><form method="post" action=""><button disabled class="button">Contact member</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel="member" and user="#displayed" user_id!="myid"]<div id="displayMemberProfile[user_id]" class="displayMemberProfile"><form method="post" action="[cb:url location="profile_view"/]"><button class="button">View full profile</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member"]<div id="displayMemberProfile[user_id]" class="displayMemberProfile"><form method="post" action=""><button disabled class="button">View full profile</button></form></div>[/cb:if]

This didn't work. I think that "user" can only be set once for each cb:if statement.

In the end I had to use javascript to hide the buttons I didn't want to show.

Here is the code that I got to work:
Code:
[cb:if user="#me" cb_userprofilelevel="member"]<div id="contactMember[user_id]" class="contactMember"><form method="post" action="/messages?option=com_uddeim&task=new&recip=[user_id]&nouserlist=7"><button class="button">Contact member</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member"]<div id="contactMember[user_id]" class="contactMember"><form method="post" action=""><button disabled class="button">Contact member</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel="member"]<div id="displayMemberProfile[user_id]" class="displayMemberProfile"><form method="post" action="[cb:url location="profile_view"/]"><button class="button">View full profile</button></form></div>[/cb:if] [cb:if user="#me" cb_userprofilelevel!="member"]<div id="displayMemberProfile[user_id]" class="displayMemberProfile"><form method="post" action=""><button disabled class="button">View full profile</button></form></div>[/cb:if] <script type="text/javascript">// <![CDATA[ $(function(){ var pathname = window.location; if (pathname == "[cb:url location="profile_view" /]") { $('.displayMemberProfile').hide(); } if ("[cb:if user_id="myid"]1[/cb:if]" == 1) { $('#contactMember[user_id]').hide(); } }); // ]]></script>
I'm a newbie at this so any help is always appreciated. Is this the best way to do this?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #221086 by krileon
Replied by krileon on topic CB substitution usage...
You can only have 1 user parameter on the substitution. You should be able to nest conditionals.

[cb:if user="#me" cb_userprofilelevel="member"]
[cb:if user="#displayed" user_id!="myid"]
<div id="contactMember[user_id]" class="contactMember"><form method="post" action="/messages?option=com_uddeim&task=new&recip=[user_id]&nouserlist=7"><button class="button">Contact member</button></form></div>
[/cb:if]
[/cb:if]

Can't recall if this'll work or not, but worth a shot.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum