Page templates
-
I am having a couple of display issues and I was wondering if you could help with the best way to do page templates for the team pages and player details. I am also having issues with the players showing in the team page back end.
-
Hi @jamesloving,
This post explains the basics of creating templates for SportsPress. Please feel free to let me know if you have any specific questions relating to this.
Regarding the Team pages, you can select Player Lists to display via the Edit Team page but the full list of players will only appear on the frontend. If you haven’t created any player lists yet, you can do so via Players > Player Lists > Add New.
I have tried creating players and plays lists, the players do not show up on the players list page.
@james Is the page online so that I could have a look? If it’s on your local machine, I’d like to see the output from SportsPress > System Status. (please use the “code” button below or wrap the code in backticks)
Ok I have a page template up now that is showing the featured image and the title, I still do not seem to be able to call any of the data points. I get array displayed. I do a bit of coding and have done page templates and I am sure i am missing something very simple. Below is the code for my single player and the environment.
Thank you again, I love the plugin!
*****************Single-player.php*****************
<?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); $player = new SP_Player( $post );?> <div class="content fullpost"> <div class="player-image"> <?php the_post_thumbnail(); ?> </div> </div> <div class="post-header"> <h1>#<?php the_title(); ?></h1> </div> <div class="post-entry"> <?php echo $player->current_teams(); ?> </div> <?php endwhile; endif; ?> <?php get_footer(); ?>
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]
*****************End Single-player.php*****************
Environment Home URL: https://vcu.dev Site URL: https://vcu.dev SP Version: 1.1.6 WP Version: 3.9.1 WP Multisite Enabled: No Web Server Info: Apache/2.4.4 (Unix) PHP/5.4.19 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3 PHP Version: 5.4.19 WP Memory Limit: 40 MB - We recommend setting memory to at least 64MB. See: Increasing memory allocated to PHP WP Debug Mode: No WP Language: Default WP Max Upload Size: 128 MB PHP Post Max Size: 128 MB PHP Time Limit: 600 PHP Max Input Vars: 1000 SUHOSIN Installed: No Default Timezone: Default timezone is UTC fsockopen/cURL: Your server has fsockopen and cURL enabled. SOAP Client: Your server has the SOAP Client class enabled. Plugins Installed Plugins: Featured Image Attribution, by Conversion Insights by Conversion Insights, Inc. version 1.0, MCE Table Buttons by Jake Goldman, 10up, Oomph version 3.1, PhotoDropper by PhotoDropper, LLC version 2.2, SportsPress by ThemeBoy version 1.1.6, UberMenu Icons by Chris Mavricos, SevenSpark version 1.1, UberMenu 2 - WordPress Mega Menu Plugin by Chris Mavricos, SevenSpark version 2.4.0.3 SP Configuration Sport: college-basketball Event Outcomes: Win (win) [10], Loss (loss) [20] Team Results: 1st Half (firsthalf) [10], 2 Half (twohalf) [20], (ot) [30], T (points) [40] Player Performance: MIN (min) [10], FGM (fgm) [20], FGA (fga) [30], FTM (ftm) [40], FTA (fta) [50], 3PM (threepm) [60], 3PA (threepa) [70], OFF REB (offreb) [80], DEF REB (defreb) [90], AST (ast) [100], PF (pf) [110], TF (tf) [120], STL (stl) [130], TO (to) [140], BLK (blk) [150], PTS (pts) [160] Table Columns: W (w = $win) [10], L (l = $loss) [20], PCT (pct = $win / $eventsplayed) [30], PF (pf = $pointsfor / $eventsplayed) [40], PA (pa = $pointsagainst / $eventsplayed) [50], DIFF (diff = ( $pointsfor - $pointsagainst ) / $eventsplayed) [60], L10 (lten = $last10) [70], STRK (strk = $streak) [80] Player Metrics: Height (height) [10], Weight (weight) [20] Player Statistics: G (g = $eventsplayed) [10], GS (gs = $eventsstarted) [20], MPG (mpg = $min / $eventsplayed) [30], FG% (fgpercent = $fgm / $fga) [40], FT% (ftpercent = $ftm / $fta) [50], 3P% (threeppercent = $threepm / $threepa) [60], RPG (rpg = ( $offreb + $defreb ) / $eventsplayed) [70], APG (apg = $ast / $eventsplayed) [80], SPG (spg = $stl / $eventsplayed) [90], BPG (bpg = $blk / $eventsplayed) [100], PPG (ppg = $pts / $eventsplayed) [110], EFF (eff = $pts + $offreb + $defreb + $ast + $stl + $blk - $fga + $fgm - $fta + $ftm + $to) [120] SP Taxonomies Leagues: A-10 (a-10), ACC (acc), NCAA (ncaa) Seasons: 2013-14 (2013-14), 2014-15 (2014-15) Venues: Siegel Center (siegel-center) Positions: SP Post Types Events: 0 publish, 1 future, 0 draft, 0 private, 0 trash, 0 auto-draft, 0 inherit Calendars: 0 publish, 0 future, 0 draft, 0 private, 0 trash, 0 auto-draft, 0 inherit Teams: 14 publish, 0 future, 0 draft, 0 private, 1 trash, 0 auto-draft, 0 inherit League Tables: 0 publish, 0 future, 0 draft, 0 private, 0 trash, 1 auto-draft, 0 inherit Players: 2 publish, 0 future, 0 draft, 0 private, 0 trash, 0 auto-draft, 0 inherit Player Lists: 1 publish, 0 future, 0 draft, 0 private, 0 trash, 0 auto-draft, 0 inherit Staff: 0 publish, 0 future, 0 draft, 0 private, 0 trash, 0 auto-draft, 0 inherit Theme Theme Name: VCU Sports Active Pages Theme Version: 2.0.3 Author URL: Templates Template Overrides: No overrides present in theme.
[Moderator Note: Please post log files between backticks or use the code button.]
@james The current_teams() function returns all sp_current_team meta as an array:
/** * Returns current teams * * @access public * @return array */ public function current_teams() { return get_post_meta( $this->ID, 'sp_current_team', false ); }
So you could assign the output to a variable and loop through it like this:
$current_teams = $player->current_teams(); if ( $current_teams ): $teams = array(); foreach ( $current_teams as $team ): $teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>'; endforeach; $label = _n( 'Current Team', 'Current Teams', count( $teams ) ); echo implode( ', ', $teams ); endif;
Hope this helps ??
Thank you, however i just get errors, I will just wait until you have a better way to do this to move forward.
I love the application, and the back end is very easy to use. I look forward to seeing future improvements.
We’re releasing our documentation very soon which will go into depth with this, and explains it a bit better than I have ??
- The topic ‘Page templates’ is closed to new replies.