• Resolved sikicz

    (@sikicz)


    Hello everyone!

    I am looking for a help. I would like to have slightly different Match Template for the User Page and the Prediction Pool Page (e.g. various “div” order).

    I found out that Prediction Page’s layout has postfix .input, so I am able to modify Match Template a little bit via CSS, but I am not able change it completely.

    I have Only Open Matches extension plugin, so I am currently using the User Page for match and prediction results and the Prediction page only for submitting predictions.

    I tried to write an extension plugin, but I don’t have the knowleadge of PHP. Is there anyone who would be willing to help me please?

    PHP code, what I tried, is bellow:
    https://codeshare.io/bvW1pO

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author AntoineH

    (@antoineh)

    hi, the correct way is to differentiate by using the $is_user_page variable that is passed to the filter footballpool_predictionform_match_template.

    So, your code should be something like below. Please note that I did not copy your entire code, the “// …” bits are there to shorten my example:

    // ...
    
    // you were not passing the correct mumber of params to your function.
    add_filter( 'footballpool_predictionform_match_template', array( __CLASS__, 'prediction_page_matches' ), null, 2 );
    
    // ...
    
    // If you look up the filter in the plugin code, you will see that only the template is passed and the is_user_page variable.
    public static function prediction_page_matches ( $match_template, $is_user_page ) {
        if ( $is_user_page )  {
            // define the template for the user page
        } else {
            // define the template for the prediction page
        }
    
        return $match_template;
    }
    
    // ...

    Hope this helps.

    Thread Starter sikicz

    (@sikicz)

    Thank you, it works perfectly!

    Bellow is the full code for another users who are looking for something simillar:

    <?php
    /*******************************************************
     *    HOW TO USE THIS PLUGIN
     *
     * 1. Save this plugin in the /wp-content/plugins folder
     * 2. Activate it via the Plugins screen in the WP admin
     *
     *******************************************************/
    
    add_filter( 'plugins_loaded', array( 'FootballPoolUserPage', 'init_extension' ) );
    
    class FootballPoolUserPage {
    	public static function init_extension() {
    		add_filter( 'footballpool_predictionform_match_template', array( __CLASS__, 'prediction_page_matches' ), null, 2 );
    	}
    	
    	public static function prediction_page_matches ( $matches, $is_user_page ) {
            if ( $is_user_page )  {
            
     /* Define Match template for User Page e.g. different CSS, reorder div... */
            
                $match_template = '<div id="match-%match_id%" class="%css_class% match-card match-type-%match_type_id%"
    								title="' . __( 'match', 'football-pool' ) . ' %match_id%">
    									<div class="match-card-header">
    										<span class="matchdate">%match_datetime_formatted%</span><span class="time">%match_time%</span>
    									</div>
    								    
    								    <div class="user-score">%user_score_txt%</div>
    									<div class="flag">%home_team_flag%</div>
    									<div class="score">
    										<a title="' . __( 'Match statistics', 'football-pool' ) . '" href="%match_stats_url%">%home_score%</a>
    									</div>
    									<div class="score">
    										<a title="' . __( 'Match statistics', 'football-pool' ) . '" href="%match_stats_url%">%away_score%</a>
    									</div>
    									<div class="flag">%away_team_flag%</div>
                                        <div class="home">%home_team%</div>
                                      	<div class="away">%away_team%</div>
                                       	<div class="stadium-name">%stadium_name%</div>
    									<div class="predikce">%user_name%</div>
    									<div class="score">%home_input%</div>
    									<div class="score">%away_input%</div>
    									    <div class="match-card-footer">
    										<div class="fp-icon">%stats_link%</div>
    										<div class="fp-icon">%joker%</div>
    									</div> 
    								</div>';
    		} else    {
     
      /* Define Match template for Prediction Page e.g. different CSS, reorder div... */
                 
                $match_template = '<div id="match-%match_id%" class="%css_class% match-card match-type-%match_type_id%"
    								title="' . __( 'match', 'football-pool' ) . ' %match_id%">
    									<div class="match-card-header">
    										<span class="matchdate">%match_datetime_formatted%</span><span class="time">%match_time%</span>
    									</div>
    								    
    								    <div class="user-score">%user_score_txt%</div>
    									<div class="flag">%home_team_flag%</div>
    									<div class="score">
    										<a title="' . __( 'Match statistics', 'football-pool' ) . '" href="%match_stats_url%">%home_score%</a>
    									</div>
    									<div class="score">
    										<a title="' . __( 'Match statistics', 'football-pool' ) . '" href="%match_stats_url%">%away_score%</a>
    									</div>
    									<div class="flag">%away_team_flag%</div>
                                        <div class="home">%home_team%</div>
                                      	<div class="away">%away_team%</div>
                                       	<div class="stadium-name">%stadium_name%</div>
    									<div class="predikce">%user_name%</div>
    									<div class="score">%home_input%</div>
    									<div class="score">%away_input%</div>
    									    <div class="match-card-footer">
    										<div class="fp-icon">%stats_link%</div>
    										<div class="fp-icon">%joker%</div>
    									</div> 
    								</div>'; 
            }
    
    		return $match_template;
    	}
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different Match Template User Page/Predictions’ is closed to new replies.