• Resolved armando.alberti

    (@armandoalberti)


    Hi guys,
    I’m using LMgr 3.9 and I’ve created a custom “matches.php” template.
    in principle this is showing only matches of latest match_day for defined league_id fetched from the shortcode BUT here is my dilemma…
    I want to use a different table format i.e. rows as follows:
    Lions 0-0 Tigers
    Hawks 3-2 Hippos
    Reds 5-0 Pinks

    …where Hawks is my team

    To build this I’m using explode PHP func usongwith match->title to split home from away teams but this as follows

    <?php $Teams=explode('&#8211', $match->title) ?>

    but $Teams[1] comes with team name but with a comma in front
    e.g
    echo $Teams[0] returns ‘Hawks’ (not bold???)
    echo $Teams[1] returns ‘;Hippos’ (comma in pos 0)

    any suggestion?
    Many thanks

    https://www.ads-software.com/plugins/leaguemanager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter armando.alberti

    (@armandoalberti)

    ‘usong’ above is a typo of mine please don’t mind to it

    Plugin Author K

    (@koelle)

    Hi,

    I don’t think this will work correctly as the home team match is shown in bold and therefore also contains HTML code.

    The following should do what you want within the loop <?php foreach ($matches AS $match) ?>

    $match->title = $teams[$match->home_team]['title'].' '.$match->score.' '.$teams[$match->away_team]['title'];
    if ( $leaguemanager->isHomeTeamMatch( $match->home_team, $match->away_team, $teams ) )
       $match->title = '<strong>'.$match->title.'</strong>';
    Thread Starter armando.alberti

    (@armandoalberti)

    Fantastic it works! Many thanks Kolja
    I haven’t considered this was containing HTML code.
    Btw you gave me the inspiration and I went a bit beyond…
    I’ve preferred to keep three data column separated (home team, score, away team) this to get columns centered evenly.
    Below my code if someone might be interested.

    <?php foreach ( $matches AS $match ) : ?>
    	     <?php $The_Home_team = $teams[$match->home_team]['title']; ?>
    	     <?php $The_Away_team = $teams[$match->away_team]['title']; ?>
                 <?php if ( $leaguemanager->isHomeTeamMatch( $match->home_team, $match->away_team, $teams ) ) : ?>
                 <? $The_Home_team = '<span style="color:#1D46A0;font-weight:bold">'.$The_Home_team.'</span>';	?>
                 <? $The_Away_team = '<span style="color:#1D46A0;font-weight:bold">'.$The_Away_team.'</span>';	?>
                 <? $match->home_points = '<span style="color:1D46A0;font-weight:bold">'.$match->home_points.'</span>';	?>
                 <? $match->away_points = '<span style="color:1D46A0;font-weight:bold">'.$match->away_points.'</span>';	?>
                 <?php endif; ?>
                  <tr class='<?php echo $match->class ?>'>
                  <td class='match' style='text-align:right'><?php echo $The_Home_team ?> </td>
                   <td class='match' valign='bottom' style='text-align:center'><?php echo $match->home_points."-".$match->away_points ?><br /><?php echo '<span style="font-size:smaller;font-style:italic;">'.$match->date." ".$match->start_time.'</span>' ?> </td>
                    <td class='match' style='text-align:left;'><?php echo $The_Away_team ?></td>
                       </tr>
    			<?php endif; ?>
    		<?php endforeach; ?>

    Hello super finish. Yet there team logos, that would be something.
    The last “endif” I had to remove. He threw me an error.

    Plugin Author K

    (@koelle)

    Very nice, but be aware that this method does not capture overtime or penalty scores. In version 3.9.0.7 I added another parameter $match->homeScore and $match->awayScore that contains the scores depending on whether the match finished after regular time, overtime or penalty. Thus simply exchange $match->home_points and $match->away_points with the above mentioned

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Canno split match->title in customized matches.php’ is closed to new replies.