Jump to content

Getting member rank in mobileNavigation template

Featured Replies

Posted

Hi there,

Could anyone explain me why I can't get the member's rank using this code in mobileNavigation template? 

 

          <div id='elUserNav_mobile-1b' class='ipsList_inline signed_in ipsClearfix'>
                  <ul id='elUserNav_mobile-2' class='ipsList_inline signed_in ipsClearfix'>
                    <li id='cUserLink'>
			<a href='{member="url()"}' id='elUserLinkb'>
				{{if isset( $_SESSION['logged_in_as_key'] )}}{lang="front_logged_in_as" sprintf="$_SESSION['logged_in_from']['name']"} {{endif}}{member="name"}
                  </a>
                  </li>
                    <li id='cUserRankcs'><p class='ipsType_reset ipsType_medium'>{$member->rank['title']}</p></li>
          </ul>
          </div>

{$member->rank['title']} works well in other templates like hovercard or profileHeader...

Thanks in advance!!

  • Author

Anyone?

😇

There's no $member variable in that template. You have to pick the loggedin user. You can do something like that:

{{$rank = \IPS\Member::loggedIn()->rank['title'];}}

and then add in the <li>:

<li>{$rank}</li>

IaY8TYy.png

ZxGSGNf.png

  • Author

hey @Adriano Faria !

Thanks for the solution! However, I did it and the editor says that there is an error in the code and I can't save the template. I'm missing something here?

			<a href='{member="url()"}' id='elUserLinkb'>
				{{if isset( $_SESSION['logged_in_as_key'] )}}{lang="front_logged_in_as" sprintf="$_SESSION['logged_in_from']['name']"} {{endif}}{member="name"}
                  </a>
                  </li>
                    {{$rank = \IPS\Member::loggedIn()->rank['title']}}
                    <li id='cUserRankcs'><p class='ipsType_reset ipsType_medium'>{$rank}</p></li>
          </ul>


 

 

I edited my post to add ;

  • Author
1 minute ago, Adriano Faria said:

I edited my post to add ;

Adriano, it worked like a charm.

Thanks A LOT!!

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.