So lets get right into it first off you need to create a select in Community > Characters > Fields > Create new Add whatever you want to the select box and save.
Next you need to figure out what the ID of the field is and you can do this by mousing over the field, by going to the edit page and looking at the URL or copy and pasting the URL into your favorite editor. That ID is what you'll replace the # with in the below code:
{expression="$groupTotals = iterator_to_array( \IPS\Db::i()->select( 'count(character_id) as total, field_#', 'characters_fields_values', array(), null, null, 'field_#' )->setKeyField( 'field_#' ) )"} <h3 class="ipsWidget_title ipsType_reset">TITLE</h3> <div class='ipsWidget_inner'> {{if $orientation == 'vertical'}} <div class='ipsPad_half'> <ul class='ipsDataList'> {{foreach $groupTotals as $theTotals}} <li class='ipsDataItem'> <div class='ipsDataItem_main ipsPos_middle'> <span class=''> {$theTotals[field_#]}</span> </div> <div class='ipsDataItem_stats ipsDataItem_statsLarge'> <span class='ipsDataItem_stats_number'>{number="$theTotals[total]"}</span> </div> </li> {{endforeach}} </ul> </div> {{else}} <div class='ipsGrid ipsGrid_collapsePhone ipsWidget_stats'> {{foreach $groupTotals as $theTotals}} <div class='ipsGrid_span2 ipsType_center cDownloadsWidget_statsNumber'> <span class='ipsType_large ipsWidget_statsCount'>{number="$theTotals[total]"}</span><br> <span class='ipsType_medium'>{$theTotals[field_#]}</span> </div> {{endforeach}} </div> {{endif}} </div>
You will also want to replace "TITLE" with your preferred block title.
You will copy this code into a brand new HTML Pages block. You create them at Pages > Blocks > Create new Block and choose "HTML" as the option.
Copy and paste it in and voila. You have a brand new block with character totals inside.
If you plan to use this in a sidebar instead of a horizontal (or bottom) block below your forum or guides you will need to add this above the rest:
{{$orientation = 'vertical';}}
This will change the layout to the list that more appropriately fits in the sidebar.
Once you have the block created, use your sidebar editor as normal and pop it onto your site. You can have as many of these sorts as you want so go select crazy!
Edited by Morrigan