[SOLVED] Dynamic field title based on subscription?

8 years 3 months ago - 8 years 3 months ago #277064 by rkreijveld
I am working in a site that has multiple profiles. Fields and tabs are shown based on the CBSubs Fields Tabs Protect plugin.

I have a field called "skills" that I use in the "person" profile as a field where a person can enter his/her skills, like administration, construction, nursing etc. The title I want to use there is "Skills offered".

I use the same field in the "organisation" profile where the organisation can enter skills the are looking for. Also like administration, construction, nursing etc. But there I want the title to be "Skills asked".

Is there a way to set the field title dynamically based on the subscription plan?

Please Log in to join the conversation.

8 years 3 months ago #277077 by krileon
Replied by krileon on topic Dynamic field title based on subscription?
Field titles support substitutions so it's possible for it to display something else based off an IF substitution. The problem is you need a CB field to condition off of. So you'll either need a CB Query Field usage setup to query for their subscription id or you need to set a fields value with CBSubs using CBSubs Fields to something unique to each plan. You'd then use a language string for the field title and translate it in your CB language files with your IF substitution in the translation. Example as follows.

Title: MY_FIELD_TITLE
'MY_FIELD_TITLE' => '[cb:if cb_profiletype="person"]Skills offered[/cb:if][cb:if cb_profiletype="organisation"]Skills asked[/cb:if]',

Ultimately it could be easier to just copy the field and have 2 of the same field or use a CB Query Field and its Query Select type to query for the values of the other one so the dropdown values at least don't have to be duplicated. This can be done with the below Query Select usage.

Query:
SELECT `fieldtitle` AS `value`, if ( `fieldlabel` != '', `fieldlabel`, `fieldtitle` ) AS `text` FROM `#__comprofiler_field_values` WHERE `fieldid` = FIELD_ID_HERE ORDER BY `ordering`
Value Column: value
Label Column: text

Be sure to replace FIELD_ID_HERE with the ID of the field you want to use for its select values.


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.
The following user(s) said Thank You: rkreijveld

Please Log in to join the conversation.

8 years 3 months ago #277078 by rkreijveld
Replied by rkreijveld on topic Dynamic field title based on subscription?
Excellet Kyle, just what I was looking for as this is a multilingual site also. Thanks!

Please Log in to join the conversation.

8 years 2 months ago #277109 by rkreijveld
Like I wrote before this works great. There seems to be one issue though.
In the profile pages the label is displayed correctly. See dl.dropboxusercontent.com/u/276508/Screenshots/Screenshot_2016-01-29_14.41.38.png
In the search fields above user lists the label seems missing: dl.dropboxusercontent.com/u/276508/Screenshots/Screenshot_2016-01-29_14.42.18.png
Is there something I can do about that?

Please Log in to join the conversation.

8 years 2 months ago - 8 years 2 months ago #277117 by krileon
You can probably use CSS to hide the Other value then use the Profile Value Layout on the spoken languages field to substitute in the Other value. Example as follows.

Profile Value Layout:
[value][cb:if cb_other!=""], [cb_other][/cb:if]

CSS
.cbProfile #cbfr_FIELD_ID {
    display: none;
}


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.

Moderators: beatnantkrileon
Time to create page: 0.231 seconds

Facebook Twitter LinkedIn