Support » Plugin: LeagueManager » [Plugin: LeagueManager] How can I add stats field to matches tables?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I resolved this by creating my own template from matches.php. I pulled code from template match.php and added it into my new matches.php template. In the following code you just need to change $stat->name to the name of your stat. Here is the snippet:

    <td>
              <?php if ( isset($match->hasStats) && $match->hasStats ) :?>
                <?php foreach ( $lmStats->get($match->league_id) AS $stat ) : ?>
    
                  <?php if ( isset($match->{sanitize_title($stat->name)}) ) : ?>
                    <?php foreach ( (array)$match->{sanitize_title($stat->name)} AS $i => $data ) : ?>
                      <?php foreach ( (array)maybe_unserialize($stat->fields) AS $field ) : ?>
                        <?php if ( isset($match->{sanitize_title($stat->name)}) && $stat->name == 'Referee' ) : ?>
                          <?php echo $data[sanitize_title($field['name'])] ?>
                          <br />
                        <?php endif; ?>
                     <?php endforeach; ?>
                   <?php endforeach; ?>
                 <?php endif; ?>
    
               <?php endforeach; ?>
             <?php endif; ?>
            </td>

    Hi klangrud,

    This seems very similar to what I want to achieve. I am editing the matches.php template to show a new column called Match Report which takes the stat field called “URL” from the stat name “report”. I’ve tried using your code but can’t seem to get it to work. The end game really that the url field simply holds a link to a post, this link then gets pulled in to the href and wrapped around the word “view” (only if there is anything in the url field, otherwise it should display nothing. Any ideas how I can achieve this?

    Hi bjonesilg,

    I just saw your question. I don’t know if you are still trying to figure this out but I might be able to help you.

    Change what I have from:

    <?php if ( isset($match->{sanitize_title($stat->name)}) && $stat->name == 'Referee' ) : ?>
      <?php echo $data[sanitize_title($field['name'])] ?>
       <br />
    <?php endif; ?>

    To:

    <?php if ( isset($match->{sanitize_title($stat->name)}) && $stat->name == 'report' ) : ?>
      <?php if ( isset($data[sanitize_title('URL')])) : ?>
        <a href="<?php echo $data[sanitize_title($field['name'])] ?>">URL</a>
        <br />
      <?php endif; ?>
    <?php endif; ?>

    Let me know how that works for you and if you have any questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: LeagueManager] How can I add stats field to matches tables?’ is closed to new replies.