Jump to content

add member clubs in hovercard

Recommended Posts


I wanna implement user clubs in hovercard like achievement section, so for this I use below codes:

{{if $member->member_id}}
        <div class='ipsFlex ipsFlex-ai:center ipsFlex-jc:between ipsMargin_top ipsFlex-as:stretch'>
                    <div class='ipsFlex ipsFlex-ai:center'>
                      <!--show last club here-->
					<div class='ipsMargin_left:half ipsType_medium'>
						<p class='ipsType_reset ipsType_semiBold'><!--show last club name--></p>
						<p class='ipsType_reset ipsType_light'><!--show last club joined date--></p>
          	<ul id="my_clubs" class="ipsCaterpillar ipsMargin_left">
                {{$clubs = 0;}}
                {{foreach \IPS\Member\Club::clubs( $member, NULL, 'name', TRUE ) as $club}}
          			<li class="ipsCaterpillar__item">
          				<span class="ipsPos_relative">
          					<a href='{$club->url()}' class='ipsUserPhoto ipsUserPhoto_tiny cClubIcon' data-ipstooltip _title='{$club->name}'>
          						{{if $club->profile_photo}}
          						<img class="ipsOutline ipsDimension:4" src='{file="$club->profile_photo" extension="core_Clubs"}' alt='{$club->name}'>
          						<img class="ipsOutline ipsDimension:4" src='{resource="default_club.png" app="core" location="global"}' alt='{$club->name}'>
                {{if $clubs >= 3}}{{break;}}{{endif}}

my result:



my problems are:

1. My code displays three of the first clubs instead of showing three of the last ones.

2. I wanna show last club with details



Edited by Arash.Ranjbar
Link to comment
Share on other sites

  • Management

The issues I see are:

  1. When ordering by name it defaults to ASC sorting, and DESC for anything else.
  2. You are loading all clubs and only display the first 3 one as the code is right now.


Try replacing the function in the foreach code with this one instead:

\IPS\Member\Club::clubs( $member, 3, 'created', TRUE )

This will specifically load the last 3 created clubs, and you can also remove the >= 3 check before the end of the foreach.

Board Rules - Available Products - Need a Custom Work?


< Don't PM me for support, post in the forum or submit a ticket from the client area instead! >

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.