[SOLVED] multicheckbox + counter

13 years 11 months ago #130925 by medaacek
[SOLVED] multicheckbox + counter was created by medaacek
Hello!

Is there any way how to read out the total number of items from multichecbox of the user profile?

example: Each user can check a list of let say 100 items,

user A check 20 different items so his list will be counted from 1 to 20

User B checks 47 different items so his list will be counted from 1 to 47

Would there be any function (Field) that would automatically count the total number of checked items?
So the user A would have in his profile something like:
Total: 20

user B:
Total: 47


Thanks a lot!!!

jiri

Post edited by: krileon, at: 2010/04/22 20:12

Please Log in to join the conversation.

13 years 11 months ago #130933 by krileon
Replied by krileon on topic Re:multicheckbox + counter
Out of the box, no. You'd need to create a new CB plugin (fieldtype plugin) in order to read out such information. I recommend reviewing document subscriber ajax text fiedltype and file fieldtype plugins for examples on creating your own. I suppose you could also edit the multi-checkbox fieldtype within cb.core.php, but we don't support core edits so can not advise you on that matter.


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 11 months ago #130990 by medaacek
Replied by medaacek on topic Re:multicheckbox + counter
Thanks, I have found different and quick solution, I have used MySQL Field Type Plugin


For those who might be interested, the solution is in thread:

www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,13/id,130928/#130928

Please Log in to join the conversation.

13 years 3 months ago #149770 by ubertramp
Replied by ubertramp on topic Re:multicheckbox + counter
Ive checked out this thread (and this particular post) but i cant see the solution on there. :blink: :blink:

Ive now added to the thread with my question on how you managed to do it, so i wont double post it here, but this is also EXACTLY what i am also trying to achieve for my site members ie. im also looking for a way that i can count up the amount of checkboxes that have been checked in a multi checkbox cb field (and once counted i can then out put it as a number)

i can list the outputs, as in print onscreen the actual names that have been checked, but i really would love to be able to present it as a figure ie user xx has xx out of xx boxes checked.

any help, pointers or tips would be VERY MUCH appreciated. Many thanks!! :silly: :silly:

Please Log in to join the conversation.

13 years 3 months ago #149777 by krileon
Replied by krileon on topic Re:multicheckbox + counter
As the thread owner is using a 3rd party plugin to achieve his goal by outputting MYSQL query content as a field there's not much I can suggest pertaining to its usage.

However, we do have a documentation subscriber incubator project called CB Query Field which allows outputting a queries results as a Field with full substitution usage. So you could use the following query for example to count a multi-checkbox field.

[code:1]
SELECT IF( `FIELD` != '', ( ( LENGTH( `FIELD` ) - LENGTH( REPLACE( `FIELD`, '*', '' ) ) ) + 1 ), 0 ) AS 'Count' FROM `#__comprofiler` WHERE `user_id` = [user_id]
[/code:1]

Replace FIELD with the actual field name (e.g. cb_multicheckbox). Count should be accurate as long as the character * is not used, if it is you'll need to likely remove it or use the query outlined in the linked thread (with adjustments of course).

Please note the example is written for our CB Query Field project which supports substitutions as used in the query.

Post edited by: krileon, at: 2010/12/31 15:57


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 3 months ago #149817 by ubertramp
Replied by ubertramp on topic Re:multicheckbox + counter
Hi Kyle,

Many thanks for the swift reply and your time in helping us out on this one.

If i can get site sponsorship then subs is something that i will be snapping up soonest. As it is at the mo though, itll cost me more than i can afford with 1000's of members :(
anyway, thats another subject!

Your query is something very similar to that which i am working on using the MySQL Field Type Plugin at the mo.

currently i have

SELECT LENGTH(cb_field1) - LENGTH(REPLACE(cb_field1, '|*|', '@@')) + 1

FROM #__comprofiler

WHERE user_id = {USERID}

...it counts the dividers (|*|)and adds '1' to the figure. This is all fine and dandy unless there are no boxes checked, in which case you can see it adds a 1 to the non existent number.

thanks again for your help and suggestions, its warming to know that i am barking up the RIGHT tree for once!!:pinch:

if i have any more breakthroughs or find other ways to get the same result ill add to this thread.

cheers

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.229 seconds

Facebook Twitter LinkedIn