• Resolved janustudios

    (@jojithedevil)


    Hi there,

    I am trying to show primary color of a club in a column in league table. The reason I am wanting to show that is because each football team has its own color of shirts and i want to show that.

    Could you please help me with that?

    Please see the code below which I have amended. I am using template paths the way documentation says.

    Thank you

    <?php
    /**
     * Standings
     *
     * @author 		Clubpress
     * @package 	WPClubManager/Templates
     * @version     2.1.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
    
    <div class="wpcm-standings-shortcode wpcm-standings">
    
    	<?php echo ( $title && ! $type == 'widget' ? '<h3>' . $title . '</h3>' : ''); ?>
    	
    	<table>
    		<thead>
    			<tr>
    				<th>Rank</th>
    				<th>Team</th>
    				<th>Team Color</th>
    				<?php
    				foreach( $columns as $column ) { ?>
    					
    					<th class="<?php echo $column; ?>"><?php echo $stats_labels[$column]; ?></th>
    				
    				<?php } ?>
    			
    			</tr>
    		</thead>
    		<tbody>
    		
    		<?php foreach ( $clubs as $club ) {
    			
    			$club_stats = $club->wpcm_stats; ?>
    			
    			<tr class="<?php echo ( $default_club == $club->ID ? 'highlighted ' : '' ); ?>">
    
    				<td class="pos">
    					<?php echo $club->place; ?>
    				</td>
    
    				<td class="club">
    					<?php 
    					echo $club->thumb;
    					if( $default_club == $club->ID ) {
    						if( $abbr == 1 ) {
    							$club_abbr = get_club_abbreviation( $club->ID );
    							echo $club_abbr;
    						} else {
    							if ( $team_label ) {
    								echo $team_label;
    							} else {
    								echo $club->post_title;
    							}
    						}
    					} else {
    						if( $abbr == 1 ) {
    							echo ( $link_club == 1 ? '<a href="' . get_the_permalink( $club->ID ) . '">' : '' );
    							$club_abbr = get_club_abbreviation( $club->ID );
    							echo $club_abbr;
    							echo ( $link_club == 1 ? '</a>' : '' );
    						} else {
    							echo ( $link_club == 1 ? '<a href="' . get_the_permalink( $club->ID ) . '">' : '' );
    							echo $club->post_title;
    							echo ( $link_club == 1 ? '</a>' : '' );
    						}
    					} ?>
    				</td>
    
    				<td>
    
    				<?php
    				//global $post;
    				$details = get_club_details( $post );
    				$primary_color_bg = ( $details['primary_color'] ) ? ' style="background-color:' . $details['primary_color'] . ';color:#fff; display: block; width: 35px; height: 35px;  border-radius: 25px;"' : '';
    				do_action( 'wpclubmanager_before_single_club' ); ?>
    				
    
    				<?php echo $club->thumb; ?>
    				<li <?php echo $club->primary_color; ?>></li>
    
    				</td>
    
    				<?php foreach( $columns as $column ) { ?>
    					
    					<td class="<?php echo $column; ?>"><?php echo $club_stats[$column]; ?></td>
    
    				<?php } ?>
    
    			</tr>
    
    		<?php } ?>
    
    		</tbody>
    	</table>
    	<?php if ( isset( $linkpage ) ) { ?>
    		<a href="<?php echo get_page_link( $linkpage ); ?>" class="wpcm-view-link">
    			<?php echo $linktext; ?>
    		</a>
    	<?php } ?>
    </div>

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Leon

    (@leonterry)

    Hi janustudios,

    No problem. This template should give you what you are after:

    
    <?php
    /**
     * Standings
     *
     * @author 		Clubpress
     * @package 	WPClubManager/Templates
     * @version     2.1.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
    
    <div class="wpcm-standings-shortcode wpcm-standings">
    
    	<?php echo ( $title && ! $type == 'widget' ? '<h3>' . $title . '</h3>' : ''); ?>
    	
    	<table>
    		<thead>
    			<tr>
    				<th>Rank</th>
    				<th>Team</th>
    				<th>Team Color</th>
    				<?php
    				foreach( $columns as $column ) { ?>
    					
    					<th class="<?php echo $column; ?>"><?php echo $stats_labels[$column]; ?></th>
    				
    				<?php } ?>
    			
    			</tr>
    		</thead>
    		<tbody>
    		
    		<?php foreach ( $clubs as $club ) {
    			
    			$club_stats = $club->wpcm_stats; ?>
    			
    			<tr class="<?php echo ( $default_club == $club->ID ? 'highlighted ' : '' ); ?>">
    
    				<td class="pos">
    					<?php echo $club->place; ?>
    				</td>
    
    				<td class="club">
    					<?php 
    					echo $club->thumb;
    					if( $default_club == $club->ID ) {
    						if( $abbr == 1 ) {
    							$club_abbr = get_club_abbreviation( $club->ID );
    							echo $club_abbr;
    						} else {
    							if ( $team_label ) {
    								echo $team_label;
    							} else {
    								echo $club->post_title;
    							}
    						}
    					} else {
    						if( $abbr == 1 ) {
    							echo ( $link_club == 1 ? '<a href="' . get_the_permalink( $club->ID ) . '">' : '' );
    							$club_abbr = get_club_abbreviation( $club->ID );
    							echo $club_abbr;
    							echo ( $link_club == 1 ? '</a>' : '' );
    						} else {
    							echo ( $link_club == 1 ? '<a href="' . get_the_permalink( $club->ID ) . '">' : '' );
    							echo $club->post_title;
    							echo ( $link_club == 1 ? '</a>' : '' );
    						}
    					} ?>
    				</td>
    
    				<td>
    					<?php $color = get_post_meta( $club->ID, '_wpcm_club_primary_color', true ); ?>
    					<span style="background: <?php echo $color; ?>; color:#fff; display: block; width: 35px; height: 35px;  border-radius: 25px;"></span>
    				</td>
    
    				<?php foreach( $columns as $column ) { ?>
    					
    					<td class="<?php echo $column; ?>"><?php echo $club_stats[$column]; ?></td>
    
    				<?php } ?>
    
    			</tr>
    
    		<?php } ?>
    
    		</tbody>
    	</table>
    	<?php if ( isset( $linkpage ) ) { ?>
    		<a href="<?php echo get_page_link( $linkpage ); ?>" class="wpcm-view-link">
    			<?php echo $linktext; ?>
    		</a>
    	<?php } ?>
    </div>
    

    Hope that helps 🙂

    Thread Starter janustudios

    (@jojithedevil)

    Thank you Leon. Its working flawlessly. I cannot thank you enough! I will go just now and add a 5 star! I would add 10 if i could!

    • This reply was modified 4 years, 1 month ago by janustudios.
    • This reply was modified 4 years, 1 month ago by janustudios.
    Thread Starter janustudios

    (@jojithedevil)

    Sorry added a duplicate comment

    • This reply was modified 4 years, 1 month ago by janustudios.
    Plugin Contributor Leon

    (@leonterry)

    Thank you Leon. Its working flawlessly. I cannot thank you enough! I will go just now and add a 5 star! I would add 10 if i could!

    You’re welcome and that would be very much appreciated 🙂

    If you ever need more help just ask and I’m always happy to help as best I can.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to show primary color of a club in a column in league-table.php’ is closed to new replies.