Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter sopedro

    (@sopedro)

    This is my template code

    <?php
    /**
     * Player Gallery
     *
     * @author 		ThemeBoy
     * @package 	SportsPress/Templates
     * @version     0.9.4
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    $defaults = array(
    	'id' => get_the_ID(),
    	'number' => -1,
    	'grouping' => null,
    	'orderby' => 'default',
    	'order' => 'ASC',
    	'itemtag' => 'div',
    	'icontag' => 'div',
    	'captiontag' => 'div',
    	'columns' => 4,
    	'size' => 'medium',
    	'show_all_players_link' => false,
    	'link_posts' => get_option( 'sportspress_list_link_players', 'yes' ) == 'yes' ? true : false,
    );
    
    extract( $defaults, EXTR_SKIP );
    
    $itemtag = tag_escape( $itemtag );
    $captiontag = tag_escape( $captiontag );
    $icontag = tag_escape( $icontag );
    $valid_tags = wp_kses_allowed_html( 'post' );
    if ( ! isset( $valid_tags[ $itemtag ] ) )
    	$itemtag = 'div';
    if ( ! isset( $valid_tags[ $captiontag ] ) )
    	$captiontag = 'div';
    if ( ! isset( $valid_tags[ $icontag ] ) )
    	$icontag = 'div';
    
    $columns = intval( $columns );
    $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    $size = $size;
    $float = is_rtl() ? 'right' : 'left';
    
    $selector = 'sp-player-gallery-' . $id;
    
    $list = new SP_Player_List( $id );
    $data = $list->data();
    
    // Remove the first row to leave us with the actual data
    unset( $data[0] );
    
    if ( $grouping === null || $grouping === 'default' ):
    	$grouping = $list->grouping;
    endif;
    
    if ( $orderby == 'default' ):
    	$orderby = $list->orderby;
    	$order = $list->order;
    else:
    	$list->priorities = array(
    		array(
    			'key' => $orderby,
    			'order' => $order,
    		),
    	);
    	uasort( $data, array( $list, 'sort' ) );
    endif;
    
    $gallery_style = $gallery_div = '';
    if ( apply_filters( 'use_default_gallery_style', true ) )
    	$gallery_style = "
    	<style type='text/css'>
    		#{$selector} {
    			margin: auto;
    		}
    		#{$selector} .gallery-item {
    			float: {$float};
    			margin-top: 10px;
    			text-align: center;
    		}
    		/* see gallery_shortcode() in wp-includes/media.php */
    	</style>";
    
    $size_class = sanitize_html_class( $size );
    $positions = get_terms( 'sp_position' );
    echo "<div class='gallery gallery-columns-{$columns} gallery-size-{$size_class}'>";
    foreach ( $positions as $position ):
    	$i = 0;
    	$position_image = '<img src="http://www.bolaseventos.pt/wp-content/themes/bolaseventos/images/sportspress/' . $position->slug  . '.png" class="attachment-thumbnail wp-post-image">';
    	if ( ! empty( $position->name ) ):
    		echo '<div class="gallery-item list-positions"><div class="gallery-back small-3 columns"><a href="#group-' . $position->slug . '" class="smoothscroll"><div class="player-position">' . $position_image . '<h5 class="image-caption">' . $position->name . '</h5></div></a></div></div>';
    	endif;
    
    endforeach;
    	echo "</div>\n";
    
    $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
    
    if ( is_int( $number ) && $number > 0 )
    	$limit = $number;
    
    if ( $grouping === 'position' ):
    	$groups = get_terms( 'sp_position' );
    else:
    	$group = new stdClass();
    	$group->term_id = null;
    	$group->name = null;
    	$group->slug = null;
    	$groups = array( $group );
    endif;
    
    foreach ( $groups as $group ):
    	$i = 0;
    
    	if ( ! empty( $group->name ) ):
    		echo '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
    		echo '<h3 class="player-group-name player-gallery-group-name">' . $group->name . '</h3>';
    	endif;
    
    	foreach( $data as $player_id => $performance ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
    
    		if ( isset( $limit ) && $i >= $limit ) continue;
    
    		$caption = get_the_title( $player_id );
    		$caption = trim( $caption );
    
    	    sp_get_template( 'player-gallery-thumbnail.php', array(
    	    	'id' => $player_id,
    	    	'performance' => $performance,
    	    	'itemtag' => $itemtag,
    	    	'icontag' => $icontag,
    	    	'captiontag' => $captiontag,
    	    	'caption' => $caption,
    	    	'size' => $size,
    	    	'link_posts' => $link_posts,
    	    ) );
    
    		$i++;
    
    	endif; endforeach;
    
    	echo '<br style="clear: both;" />';
    
    endforeach;
    
    echo "</div>\n";
    
    if ( $show_all_players_link )
    	echo '<a class="sp-player-list-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all players') . '</a>';
    ?>
    <script type="text/javascript">
     jQuery(function() {
      jQuery('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
          var target = jQuery(this.hash);
          target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            jQuery('html,body').animate({
              scrollTop: target.offset().top
            }, 1000);
            return false;
          }
        }
      });
    });
    </script>
    Plugin Author ThemeBoy

    (@themeboy)

    Ah, you’ll need to change the line:

    $groups = get_terms( 'sp_position' );

    to:

    $groups = get_terms( 'sp_position', 'orderby=slug' );

    Let me know if that works.

    Thread Starter sopedro

    (@sopedro)

    Hi Themeloy,

    Thanks, It works.

    Regards,

    Plugin Author ThemeBoy

    (@themeboy)

    Awesome, glad I could help!

    pstacks

    (@pstacks)

    ThemeBoy, do you answer general questions about your sportspress theme?

Viewing 5 replies - 16 through 20 (of 20 total)

The topic ‘Player Page’ is closed to new replies.