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

Character Tab in Member Profile


Recommended Posts

So I haven't worked out how to do a who's who list (I got so close but no dice).

 

I have worked out how to create a characters tab on your main profile.

 

First things first, we create a block.

 

Block

Go to Pages > Blocks > Create New Block

 

You want to select Custom > Manual PHP and then Next

Name is whatever. Category is whatever. Template Key is something memorable. I use char-list.

 

Go to Content and paste in the following

$select = (\IPS\Db::i()->select('*', 'characters_characters', array('character_owner_id', 'character_name'), 'character_name ASC'));
$thismember = \IPS\Member::load( \IPS\Request::i()->id );

foreach ($select as $characters) {
	$id = $characters[character_owner_id];
	$mid = $thismember->member_id;
	$charurl = (str_replace(' ', '-', ($characters[character_name])));
if ($id === $mid) {
print "<a class='character' style='display: block;' href='/character/" . $characters[character_id] . "-{$charurl}'>" . $characters[character_name] . "</a>";
}}

Save and give it the correct permissions.

 

Template

Now we need to add it to the template.

 

Go to your theme > Edit HTML & CSS

 

Under Templates go to core > profile > profileTabs

 

Find the following

{{foreach $tabs as $tab => $title}}
                <li>
                    <a href='{$member->url()->setQueryString( 'tab', $tab )}' id='elProfileTab_{$tab}' class='ipsTabs_item ipsType_center {{if $activeTab == $tab}}ipsTabs_activeItem{{endif}}' role="tab" aria-selected="{{if $activeTab == $tab}}true{{else}}false{{endif}}">{lang="$title"}</a>
                </li>
            {{endforeach}}

Add the following below the {{endforeach}}

<li>
  <a href='{$member->url()->setQueryString( 'tab', 'characters' )}' id='elProfileTab_characters' class='ipsTabs_item ipsType_center {{if $activeTab == characters}}ipsTabs_activeItem{{endif}}' role="tab" aria-selected="{{if $activeTab == characters}}true{{else}}false{{endif}}">Characters</a>
</li>

 

Find the following:

{{foreach $tabs as $tab => $title}}
		{{if $activeTab == $tab}}
			<div id="ipsTabs_elProfileTabs_elProfileTab_{$tab}_panel" class='ipsTabs_panel ipsAreaBackground_reset'>
				{$activeTabContents|raw}
			</div>
		{{endif}}
	{{endforeach}}

Add this after the {{endforeach}}

<div id="ipsTabs_elProfileTabs_elProfileTab_characters_panel" class='ipsTabs_panel ipsAreaBackground_reset'>
  {block="char-list"}
</div>

Save the template and go to your profile. You should now have a Character tab on your profile with a list of your characters with a link to their profile! Nice and simple for now.

Edited by Kit the Human
  • Love 2

 

sig.png.30b42565d04d922988370bf14e1447bc.png

PSI: an Occult Investigations RP

Roleplay Architects: Grab a friend (or many friends!) and just write.

You can also find me at:

static-historicalrp.jpg  B8CB4x.png rpabutton.png

Link to post
Share on other sites
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Posts

So I haven't worked out how to do a who's who list (I got so close but no dice).   I have worked out how to create a characters tab on your main profile.   First things first, we c

Posted Images

I've been trying to work out how I would get the latest post, but not having much luck. In the meantime for something a bit nicer

Capture.PNG.1066abca54cc26dc1d4ade290f6208d2.PNG

 

This will just display the character avatar and their title in the list

$select = (\IPS\Db::i()->select('*', 'characters_characters', array('character_owner_id', 'character_name'), 'character_name ASC'));
$thismember = \IPS\Member::load( \IPS\Request::i()->id );

print "<ul class='ipsDataList'>";
  
foreach ($select as $characters) {
	$id = $characters[character_owner_id];
	$mid = $thismember->member_id;
	$charurl = (str_replace(' ', '-', ($characters[character_name])));
  
if ($id === $mid) {
print "
<li class='ipsDataItem '>
  <div class='ipsDataItem_icon ipsPos_top'>
    <a href='/character/" . $characters[character_id] . "-{$charurl}' data-ipshover data-ipshover-target='/character/" . $characters[character_id] . "-{$charurl}/do=hovercard' class='ipsUserPhoto ipsUserPhoto_tiny' title='Go to " . $characters[character_name] . "profile'>
      <img src='/uploads/" . $characters[character_avatar] . "' data-src='/uploads/" . $characters[character_avatar] . "' alt='" . $characters[character_name] . "'style='height:auto;'>
    </a>
  </div>
  <div class='ipsDataItem_main ipsType_medium ipsType_break'>
    <p class='ipsType_medium ipsType_reset'>
      <a href='/character/" . $characters[character_id] . "-{$charurl}'>" . $characters[character_name] . "</a>
    </p>
    <div class='ipsType_richText ipsContained'>" . $characters[character_title] . "</div>
  </div>
</li>";
}}

print "</ul>";

(The hover operates in a somewhat unexpected manner but it's amusing so)

Edited by Kit the Human

 

sig.png.30b42565d04d922988370bf14e1447bc.png

PSI: an Occult Investigations RP

Roleplay Architects: Grab a friend (or many friends!) and just write.

You can also find me at:

static-historicalrp.jpg  B8CB4x.png rpabutton.png

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.



×
×
  • 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.