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

Character Mod: Playby list
   (0 reviews)

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.

    Software: Invision Power Services (IPS) 204,190,166,165

So the Character Mod will likely hold all of your character's information. It's a matter of pulling that information out and being able to utilize it elsewhere to make lists. Below is the code for a Playbys list however can work for other things.

 

With the new version of the Character Mod it is not required to do this for groups as the Character List allows you to filter by groups now.

 

So first things first, you need to create your custom field for the plaby/faceclaim that your users will be able to edit and add their plaby into. If you already have this then skip to the next step. To do this you need to go to Community > Characters > Custom Fields > Create New > Create a Text Field. Whether you show it in the posts or profile or not is irrelevant. In our example below the key we use is "playby" so you need to use this or make sure to change it in the code.

Once you have this created you need the field ID. To find this you can mouse 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 into an HTML block in Pages (Pages > Blocks > Create New > Custom HTML):

 

<div class='ipsPad'>
<h2 class="ipsType_sectionTitle ipsType_reset cForumTitle">Playby List</h2>
<div class="ipsPad ipsBox">
	{{$runit = \IPS\Db::i()->select('*', 'characters_fields_values', 'field_# != ""', 'field_# ASC');}}
	<ul class='ipsDataList ipsDataList_reducedSpacing playbyList ipsGrid ipsGrid_collapsePhone' data-ipsgrid data-ipsgrid-equalheights="row">
		{{foreach $runit as $playbys}}
				{{$char = \IPS\characters\Character::load( $playbys[character_id]);}}
      {{if $char->approved == 1}}
<li class="ipsPhotoPanel ipsPhotoPanel_small ipsAreaBackground_reset ipsClearfix ipsGrid_span4 ipsPad">
					<span class="ipsUserPhoto ipsUserPhoto_small ipsPos_top">
							{{if $char->photo}}
								<img src="{file="$char->photo"}" alt="$char->name" />
							{{else}}
								<img src='{resource="default_photo.png" app="core" location="global"}' alt="$char->name">
							{{endif}}
					</span>
				<div class="">
                  <strong>Playby:</strong> {$char->fields('playby')}
					<br /><strong>Character:</strong> {template="link" app="characters" location="front" group="character" params="$char"}			  
					<br /><strong>Played by:</strong> 
                  {$char->owner()->link()|raw}
				</div>
			</li>
      {{endif}}
		{{endforeach}}
	</ul>
</div>
</div>

This code will give you a simple list with an image to the side, the playby, the character and the player that plays the character. It is in a grid view and you can edit as necessary but it's in alphabetical order by first name of the playby.

 

To explain the code a little we first tell the code to find all characters that have a playby filled in so the field is "not blank". Then we loop through those (where the foreach starts) to show them. To get the character name and player name we first load the character then check to be sure they are approved, because we only want approved characters showing in our lists, and then we output how we want everything to look.

 

You're free to ask questions in the IPS Staff People Coterie or get assistance. Please feel free to leave a review below.

Edited by Morrigan


  • Love 2
Sign in to follow this  

Related Guides



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.