Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  

How to create custom total Blocks with the Character Mod
   (0 reviews)

Morrigan
  • As it stands there is a default total block in the application itself however that only works for groups and if you want other sorts of totals manually updating them is... well lets face it, a pain in the ass. For this guide I'm going to give you the code and how to edit it. This should only be used on things that only have one selection on a select box (so no arrays). You can do this for factions, genders, whatever you have that needs a total.

    Software: Invision Power Services (IPS)

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


Sign in to follow this  

Related Guides

  • Morrigan

    I've been asked a few times on how to make a custom Playby List without having to create a separate directory for claims. This will work for many different things that only have one level like Faction or Species. Job lists, if you want them separated by location, are more complicated and will be covered in another guide.

    IPS



User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Guidelines and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.