WordPress.org

Ready to get started?Download WordPress

Forums

Football Pool
[resolved] Editing class-football-pool.php to create extra "prediction" pages (3 posts)

  1. LABCAT
    Member
    Posted 1 year ago #

    Hi there,

    For the tournament I am creating I want to separate the "prediction" page into several pages and only display events for a particular month etc.

    I can edit (class-football-pool-pool-page.php) to display the data how I want but I can't figure how to create duplicates of the "prediction" page upon activation.

    private static $pages = array(
    						array( 'slug' => 'tournament', 'title' => 'matches', 'comment' => 'closed' ),
    							array( 'slug' => 'teams', 'title' => 'teams', 'parent' => 'tournament', 'comment' => 'closed' ),
    							array( 'slug' => 'groups', 'title' => 'groups', 'parent' => 'tournament', 'comment' => 'closed' ),
    							array( 'slug' => 'stadiums', 'title' => 'venues', 'parent' => 'tournament', 'comment' => 'closed' ),
    						'rules' => array( 'slug' => 'rules', 'title' => 'rules', 'text' => '' ),
    						array( 'slug' => 'pool', 'title' => 'march', 'comment' => 'closed' ),
    						array( 'slug' => 'pool', 'title' => 'april', 'comment' => 'closed' ),
    						array( 'slug' => 'pool', 'title' => 'may', 'comment' => 'closed' ),
    						array( 'slug' => 'ranking', 'title' => 'ranking', 'comment' => 'closed' ),
    						array( 'slug' => 'statistics', 'title' => 'charts', 'comment' => 'closed' ),
    						array( 'slug' => 'user', 'title' => 'predictions', 'comment' => 'closed' )
    					);

    I thought it would be as simple as adding the extra lines to the pages array as I have done above, but I was wrong. This does change the page title of the "prediction" page to "march" but does not create the "april" or "may" pages.

    Could you please lead me in the right direction?

    http://wordpress.org/extend/plugins/football-pool/

  2. AntoineH
    Member
    Plugin Author

    Posted 1 year ago #

    You have to define different slugs for each of the pages. For every page added via the array the page_ID is stored in the WP options. If an option with the same page_name (slug) already exists, the page won't be created.

    Secondly, you have to let the plugin know that these new pages have to call the logic to display the prediction form. The function the_content in the same class file you're working in now, handles this.
    If you're calling the same function for every page I guess it should be changed to something like this:

    case Football_Pool_Utils::get_fp_option( 'page_id_slug1' ):
    case Football_Pool_Utils::get_fp_option( 'page_id_slug2' ):
    case Football_Pool_Utils::get_fp_option( 'page_id_slug3' ):
    case Football_Pool_Utils::get_fp_option( 'page_id_slug4' ):
    	$page = new Football_Pool_Pool_Page();
    	$content .= $page->page_content();
    	break;

    (disclaimer: above was not tested so it may need some more work)

    Please note: if you change the plugin's code you won't be able to upgrade to future versions as this would break your changes. Or make sure you back-up your changes before upgrading.

  3. AntoineH
    Member
    Plugin Author

    Posted 1 year ago #

    BTW I like the idea of having multiple prediction forms that can be switched off and on, or displayed individually. I added it on my feature list for a future version.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.