Jump to content

Recommended Posts

Posted (edited)

hi

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>
					</div>
					</div>
          	<ul id="my_clubs" class="ipsCaterpillar ipsMargin_left">
                {{$clubs = 0;}}
                {{foreach \IPS\Member\Club::clubs( $member, NULL, 'name', TRUE ) as $club}}
          				{{$clubs++;}}
          			<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}'>
          						{{else}}
          						<img class="ipsOutline ipsDimension:4" src='{resource="default_club.png" app="core" location="global"}' alt='{$club->name}'>
          						{{endif}}
          					</a>
          				</span>
          			</li>
                {{if $clubs >= 3}}{{break;}}{{endif}}
                {{endforeach}}
          	</ul>
        </div>
        {{endif}}
        {{endif}}

my result:

Spoiler

1559712537_Screenshot2023-07-08145801.png.3cb4c30673c704d39530f93ca989413e.png

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

 

thanks!

Edited by Arash.Ranjbar
  • Management
Posted

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! >

Posted

thanks to help. :beach:

This topic can be closed.

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.