Ranking table
-
Hi.
I need help with the ranking table is it possible to have for example
USER | FULL SCORE | TOTO SCORE | GOAL BONUS | TOTAL
P1 | 24 | 10 | 6 | 40
P2 | 16 | 5 | 4 | 25Instead of just showing the total?
I have the Football Pool Ranking Template Extension, but still need some guidance.
-
I already have an extension for this that you can alter to your needs: score breakdown.
Is it possible to show the profile picture of the users when using this extension?
Yes, that’s possible. The placeholder
%user_avatar%
is already in the template, but it is disabled by default because WordPress fires extra queries for every user that is shown in the ranking. You can enable the avatar by defining the following constant in your wp-config.php:define( 'FOOTBALLPOOL_NO_AVATAR', false );
As a reference: on my install with a ranking of 54 users the total amount of queries for the ranking page is 33 without the avatar and 139 (!) with the avatar. That’s 2 extra queries per user in the ranking (because I am logged in my 2 queries are counted in both cases). That is the reason why I disable it by default: it slows down the ranking page.
Haha, lot of searching. I put this in the wp-config, both didn’t do anything:
define( ‘FOOTBALLPOOL_MATCH_DATE_FORMAT’, ‘j F Y’ );
define( ‘FOOTBALLPOOL_NO_AVATAR’, ‘false’ );
Turned out I used a different ‘ at the date format and I put ” around false ?? Both date and avatar now work and true, it’s much slower.
Now I created a separate page with an overview of all the players with [fp-user-list]. Would it be possible to make the players name link to their profile?
Now I created a separate page with an overview of all the players with [fp-user-list]. Would it be possible to make the players name link to their profile?
Only if you create your own extension. There is a row template in the shortcode that you can overwrite with the filter
footballpool_fp-user-list_template_row
.The user ID is available as a template parameter:
%user_id%
. So adding the link should be relatively straightforward.Hi Anthoine, as we know little of PHP, we got one of your plugins to start with and thought we replaced it right, but it’s not working. Could you help? We want to make a community thing between the players so everyone can see profile of other players and make it more of a party (at 1,5 meters ?? )
class FootballPoolExtensionRankingRowTemplate { public static function init_extension() { add_filter( 'footballpool_fp-user-list_template_row', array( __CLASS__, 'new_template' ), null, 2 ); } public static function new_template( $all_user_view, $type ) { $ranking_template = '<tr class="%css_class%"> <td class="user-rank">%rank%.</td> <td class="user-name"><a href="%user_id%">%user_name%</a></td> <td class="user-score ranking score">%points%</td> <td class="user-league">%league_image%</td> </tr>'; return $ranking_template; } } add_filter( 'plugins_loaded', array( 'FootballPoolExtensionRankingRowTemplate', 'init_extension' ) );
The link should be something like:
<a href="/user/?user=%user_id%">
The /user/?user= part is something that you should copy from the links on your ranking page, because I do not know what your path to the user page is.
-
This reply was modified 3 years, 9 months ago by
AntoineH. Reason: html messed up
OK, superthx, let’s try that. But is the set up for our first and only plugin ever ok?
So far it’s not showing in the plugin page :-S
-
This reply was modified 3 years, 9 months ago by
sezercik.
You have to start the file with a plugin header. Otherwise WP will not recognize it as a plugin.
E.g.
<?php /** * Plugin Name: Football Pool Extension * Description: Add link to user page to [fp-user-list]. * Author: sezercik */
And, just to be sure, it is best that you also change the class name to avoid conflicts with an extension that has the same class name.
Rest looks okay ??
Antoine,
No offense of course, but is this right?
footballpool_fp-user-list_template_row
I’ve tried a lot, but nothing changes in the [fp-user-list] output. Plugin is activated and everything. I tried finding if it works by putting more dots behind rank. The dots don’t show in the output.
This is the code:
<?php /** * Plugin Name: Football Pool User List * Description: Add link to user page to [fp-user-list]. * Author: sezercik */ //** Save this plugin in the wp-content/plugins folder and activate it **// class FootballPoolUserListLink { public static function init_extension() { add_filter( 'footballpool_fp-user-list_template_row', array( __CLASS__, 'new_template' ), null, 2 ); } public static function new_template( $all_user_view, $type ) { $list_template = '<tr class="%css_class%"> <td class="user-rank">%rank%....</td> <td class="user-name"><a href="user/%user_id%">%user_name%"</a></td> <td class="user-score ranking score">%points%</td> <td class="user-league">%league_image%</td> </tr>'; return $list_template; } } add_filter( 'plugins_loaded', array( 'FootballPoolExtensionListRowTemplate', 'init_extension' ) );
-
This reply was modified 3 years, 9 months ago by
sezercik.
Yes, if you’re planning to change the template for the fp-user-list shortcode, then
footballpool_fp-user-list_template_row
is right. The problem with your script is that you renamed your class, but you did not change the class name in the callback reference on the last line of your script (add_filter). Once that is solved, you will see that the changed template is used for the shortcode.p.s. I noticed that you introduced some new placeholders (e.g. %rank%). If this is intentional, then you also need to define the values for these via the
footballpool_fp-user-list_template_row_params
filter.Hi Antoine,
I was wondering if it would be possible to redirect the predictions of a user to a specific part (for example a container) on a page. Instead of that the predictions are shown on a full page.
Great work you did with this plugin. Much appreciated!
-
This reply was modified 3 years, 9 months ago by
- The topic ‘Ranking table’ is closed to new replies.