ArashDev Posted July 8, 2023 Posted July 8, 2023 (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 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 July 8, 2023 by Arash.Ranjbar
Management terabyte Posted July 8, 2023 Management Posted July 8, 2023 The issues I see are: When ordering by name it defaults to ASC sorting, and DESC for anything else. 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. ArashDev 1 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! >
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now