×

Error

Please login first

What would it take to create a custom field?

13 years 2 months ago #156516 by ObSethed
I have a website devoted to skiers and snowboarders, it's a community site, we use community builder because it's the best solution out there ;)

I would like to add a field into the users profile, it would be a "total vertical" field, referring to the amount of vertical they ski/ride. The idea would be a user would log in and from their front end they would input their vertical and it would add to their total and automatically update the amount displayed, without them having to do the math and change the total value of the field every time they wanted to update their skied/ridden vertical.

Is it possible to create such a field? if so how would i do that?
If i need to clarify more please let me know, it sounds somewhat confusing but the idea is rather simple.

Thanks!

Please Log in to join the conversation.

13 years 2 months ago #156530 by nant

Please Log in to join the conversation.

13 years 2 months ago #156598 by ObSethed
It would be a field that has an initial value set at registration. but the values added afterwards would be added to the existing value. It'd be a numeric field, that does simple math,

so the user at registration has skied 10000 feet.
last weekend they skied another 10000 feet.
In their profile they would enter 10000 into the field.
the field would then display 20000 feet.

is it possible to do this?

Please Log in to join the conversation.

13 years 2 months ago #156703 by krileon
CB does not have such a field. Couldn't the user just provide the math themselves and update the field to 20000? Otherwise you'd need to develop a new fieldtype plugin in order to provide such a field. You could use ajax file fieldtype plugin as an example.


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.

13 years 2 months ago #157064 by ObSethed
The user could indeed do the math themselves, but to add convenience to the field it would make more sense if it just did the math automatically. So what would be the best route to take on custom field development?

Please Log in to join the conversation.

13 years 2 months ago - 13 years 2 months ago #157192 by krileon
Ok, this can be done.. will be tricky, but can be done. You'll need 2 fields, both being Integer types. Your first field would be for example cb_adddistance then your second would be for example cb_distance. The cb_distance field needs to be Read Only. You will need CB Fields incubator project for this to work. Once installed configure 2 triggers. The first trigger will be for example the below setup.

(this one must be first! change the order if necessary)
Trigger: onAfterUserUpdate,onAfterUpdateUser
Access: Registered (add more usergroups if you like)
Conditional:
-Field: cb_adddistance
-Operator: Not Empty
Field: cb_distance
Operator: Add
Value: [cb_adddistance]

The above will take cb_adddistance and add it to the read only field cb_distance. Now that we've updated the distance we need to empty out cb_adddistance. To do this you'll need a second trigger configured as follows.

(this one must be second! change the order if necessary)
Trigger: onAfterUserUpdate,onAfterUpdateUser
Access: Registered (add more usergroups if you like)
Field: cb_adddistance
Operator: Set
Value: (leave blank)

With the above it will empty the cb_adddistancefield so user can add more distance as they see fit.


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.252 seconds

Facebook Twitter LinkedIn