Create New Page Template

Community Forums Forums General Discussion Create New Page Template

This topic is: not resolved

This topic contains 25 replies, has 5 voices, and was last updated by  marybaum 1 year, 8 months ago.

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #25486

    BennettGlobal
    Participant
    Post count: 16

    I want to create an additional page template for my site http://www.bgemagazine.com, that I can place widgets in that are independent from my home page.  I would like that template to have the exact same layout as my home page, but with the ability to put a different sliders in with different content.  I want the ability to put a different slider on this page with different content than my home page.  It is my understanding that I would have to use a different slider than the one Genesis used on my homepage.

    For example:  The ENTERTAINMENT link in my secondary menu, I would like users to click on that page and see content in the slider area and below that’s different than the homepage.  Users should have the ability to post comments to individual postings just like the remainder of the site.

    Is this possible, and if so, how?  I am very new to this and my coding expertise is limited, so don’t be afraid to lay things out for me in layman terms, I definitely won’t be offend.  I just want to get it correct.

    Thank you in advance…

    Michael

    #25571

    braddalton
    Participant
    Post count: 10575

    I did this on a local installation of WordPress with the Magazine theme and it worked.

    I duplicated the PHP code in functions.php for registering widget areas and renamed all code with home to custom and pasted at the end of the file.
    Did the same with all the CSS code which included home to custom
    Copied and renamed the home.php to custom.php and renamed all instances of home to custom
    Added template name to the custom.php file
    /*
    Template Name: Custom
    */

    You’ll need to use another Slider plugin, i recommend the Easing Slider plugin


    #25887

    marybaum
    Participant
    Post count: 132

    I’m working on the same thing and getting a server error.

    The new page is http://www.frontenactennis.com/its-tourney-time/.

    page_tourney.php:

    <?php

    /*
    Template Name: Tourney
    */

    add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_full_width_content’ );
    add_filter( ‘body_class’, ‘minimum_add_body_class’ );

    function minimum_add_body_class( $classes ) {
    $classes[] = ‘tourney';
    return $classes;
    }
    remove_action( ‘genesis_after_post_content’, ‘genesis_post_meta’ );
    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );

    add_action( ‘genesis_meta’, ‘minimumFRC_tourney_genesis_meta’ );
    /**
    * Add widget support for tourney page.
    *
    */
    function minimumFRC_tourney_genesis_meta() {

    if ( is_active_sidebar( ‘tourney-featured-left’ ) || is_active_sidebar( ‘tourney-featured-right’ ) ) {

    add_action( ‘genesis_after_header’, ‘minimumFRC_tourney_loop_helper’ );

    }
    }

    /**
    * Display widget content for tourney featured sections.
    *
    */
    function minimumFRC_tourney_loop_helper() {

    if ( is_active_sidebar( ‘tourney-featured-left’ ) || is_active_sidebar( ‘tourney-featured-right’ ) ) {

    echo ‘<div id=”tourney-featured”><div class=”wrap clearfix”>';

    echo ‘<div class=”tourney-featured-left”>';
    dynamic_sidebar( ‘tourney-featured-left’ );Pa
    echo ‘</div><!– end .tourney-featured-left –>';

    echo ‘<div class=”tourney-featured-right”>';
    dynamic_sidebar( ‘tourney-featured-right’ );
    echo ‘</div><!– end .tourney-featured-right –>';

    echo ‘</div><!– end .wrap –></div><!– end #tourney-featured –>';

    }
    }

     

    genesis();

    I’ve styled the new classes and registered the sidebar areas in functions.php – clearly there’s more I’m missing. Originally I had gotten even more ambitious and added a middle widget area, but thought I could solve the problem by going back to a direct clone of the home page. I will style the featured-left area differently – with two columns – to make up the difference.

    Thanks for the tip about the Template Name – I’d missed that before and not even had the template show up in the page editor.

    All the best,

     

    Mary Baum

     


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #25898

    stacyvlasits
    Participant
    Post count: 6

    Mary, my guess is that you are putting a function declaration in your template file that has already been declared elsewhere (most likely in functions.php). You can fix this by removing the function declaration from the template file.

    My guess is that this is the culprit:
    function minimum_add_body_class( $classes )

    #25924

    marybaum
    Participant
    Post count: 132

    Sounds like I should take it out of the template above. Thanks! I’ll try that.

    MB


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #26059

    marybaum
    Participant
    Post count: 132

    Didn’t seem to make a difference.

    I also fixed the egregious typo at the end of

    dynamic_sidebar( ‘tourney-featured-left’ );Pa and got rid of the superfluous Pa that didn’t belong – also didn’t change anything.

    I noticed that the landing page template has a custom body class function:

    // Add custom body class to the head
    add_filter( ‘body_class’, ‘minimum_add_body_class’ );
    function minimum_add_body_class( $classes ) {
    $classes[] = ‘minimum-landing';
    return $classes;
    }

    So I tried something like that with Tourney, but that didn’t change the server error either.

    I also tried renaming the function.

    The new page displays happily if I switch to the landing-page template. I suppose I could add the content as a bunch of static html, but I want to learn to do it this way.

     

     


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #26072

    BennettGlobal
    Participant
    Post count: 16

    I’m having some problems trying to create a page template and I need some help.  My site is bgemagazine.  My goal, was to create a page called ENTERTAINMENT.  This page would have the exact same layout as my Home page, but use a different slider.  They objective here is to not only create a different slider (I understand I will need to use a non-Genesis slider) but to have certain categories of posts appear on this entertainment page.

    The steps I’ve taken so far:

    I went into my cPanel on Host Gator with the following code to create a php file called pages_entertainment.php.  When I go back to my Dashboard to create a new page, the drop down menu for page type gives me the option to select Entertainment.  It also appears in my Editor under Genesis.  When I created a test page using the Entertainment template and placed it in Secondary Navigation bar it seemed fine.  Then when I went to open the page it gave me this error:

    Parse error: syntax error, unexpected T_STRING in /home/bgeinc/public_html/wp-content/themes/genesis/page_entertainment.php on line 12

    According to my code editor in Host Gator this is line 12….

    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );\

    ——————————————————————————————————————————————————–
    *  Template Name: Entertainment    */
    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );
    add_action( ‘genesis_loop’, ‘magazine_entertainment_loop_helper’ );
    /**
    * Add widget support for entertainmentpage. If no widgets active, display the default loop.
    *
    */
    function magazine_entertainment_loop_helper() {

    if ( is_active_sidebar( ‘entertainment-top’ ) || is_active_sidebar( ‘entertainment-left’ ) || is_active_sidebar( ‘entertainment-right’ ) || is_active_sidebar( ‘entertainment-bottom’ ) ) {

    if ( is_active_sidebar( ‘entertainment-top’ ) ) {
    echo ‘<div class=”entertainment-top”>';
    dynamic_sidebar( ‘entertainment-top’ );
    echo ‘</div><!– end .entertainment-top –>';
    }

    if ( is_active_sidebar( ‘entertainment-left’ ) || is_active_sidebar( ‘entertainment-right’ ) ) {

    echo ‘<div class=”entertainment-middle”>';

    if ( is_active_sidebar( ‘entertainment-left’ ) ) {
    echo ‘<div class=”entertainment-left”>';
    dynamic_sidebar( ‘entertainment-left’ );
    echo ‘</div><!– end .entertainment-left –>';
    }

    if ( is_active_sidebar( ‘entertainment-right’ ) ) {
    echo ‘<div class=”entertainment-right”>';
    dynamic_sidebar( ‘entertainment-right’ );
    echo ‘</div><!– end .entertainment-right –>';
    }

    echo ‘</div><!– end .entertainment-middle –>';

    }

    if ( is_active_sidebar( ‘entertainment-bottom’ ) ) {
    echo ‘<div class=”entertainment-bottom”>';
    dynamic_sidebar( ‘entertainment-bottom’ );
    echo ‘</div><!– end .entertainment-bottom –>';
    }

    }

    else {
    genesis_standard_loop();
    }

    }

    genesis();
    ———————————————————–

    What am I doing wrong?  Is this the right approach for my desired result.  I’m a neophyte at this so be easy on me…

    #26077

    marybaum
    Participant
    Post count: 132

    Since you and I seem to be at about the same stage, I suggest you take what I say with a grain of salt. One thing that jumps out at me: you have a div for entertainment-middle but no php registering it as a widget area.

    I’d be tempted to change this:

    if ( is_active_sidebar( ‘entertainment-left’ ) || is_active_sidebar( ‘entertainment-right’ ) ) {

    echo ‘<div class=”entertainment-middle”>’;

    to mirror your next code block exactly, only be all about entertainment-middle. Like maybe –

    if ( is_active_sidebar( ‘entertainment-middle’ ) ) {
    echo ‘<div class=”entertainment-middle”>’;
    dynamic_sidebar( ‘entertainment-middle’ );
    echo ‘</div><!– end .entertainment-middle –>’;

    And I’m assuming you’re then – or beforehand – (who cares about chronology?) registering all these new widget areas in functions.php, right? I think it would be very easy to get tired and forget to do that – especially since I think you have six of them. In fact, I could see myself pulling just such a stunt and then wondering why the widgets weren’t showing up on the Widgets page in the Admin area . . . ;-)

    Now then – here’s hoping someone who has actual php expertise can shed some light on both your and my problems in this area. I have approximately 48 hours until I put some print stuff to bed, and then I have to get my tourney info up one way or the other before the stuff gets delivered, and I’m sure you don’t have until next fall . . . ;-)

    Waiting with my new BFF …

    MB


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #26081

    BennettGlobal
    Participant
    Post count: 16

    Hi MB,

    Glad to have a new BFF who not only shares my problems, but my initials as well.  I will test your theory momentarily.

    Yes, the Magazine Child Theme has six widget areas.  I am essentially trying to keep the ENTERTAINMENT page in the same format as my home page, but with the flexibility to put things in certain key categories and have a widget that allows some of my images in the slider to differ from the Home page.  I just copied the php code as is and changed the name to reflect my new template name.  It looked pretty easy, but obviously I missed something.

    I have a little more time than you do.  I was planning on being live by the end of this month.  My plans are somewhat ambitious long term, but I’ve got to get started.

    I’m glad you reminded me about the functions.php.  I did remember to add those widget areas, but honestly, I forgot I did it until just now.

    Hopefully a php genius will come along shortly and solve both of our problems.

    The other MB…

    #26082

    Bill Murray
    Participant
    Post count: 575

    @BennetGlobal & MB – If you post the code you are using to a Pastebin and include a link here, I’ll tell you what’s wrong with the code in the pastebin. It’s too hard to follow the back and forth here with my simple mind.


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #26088

    marybaum
    Participant
    Post count: 132

    Okay – here’s a latest version. Thought it might be a good idea to imitate the landing page and disable all the page parts this template doesn’t use – you’ll notice (if you care) the home page doesn’t use them either, but I just hid them with css.

    http://pastebin.com/tYRDrMDy

    MB

    Relevant functions:

    http://pastebin.com/QkVwX9Cy

     


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #26090

    BennettGlobal
    Participant
    Post count: 16

    Hi Bill,

    http://pastebin.com/i5iNpFuw

    This is the error message I received if that helps.  Let me know if you need more information.

    Parse error: syntax error, unexpected T_STRING in /home/bgeinc/public_html/wp-content/themes/genesis/page_entertainment.php on line 12

    Michael (BennettGlobal)

    #26092

    braddalton
    Participant
    Post count: 10575

    I’ve written a tutorial about this which includes the code for the Magazine theme which might help.

    All the code is on Github https://gist.github.com/braddalton


    #26102

    marybaum
    Participant
    Post count: 132

    Well. Suddenly the code I posted on Pastebin is working!

    With one change, anyway:

    I changed this action and function on pastebin:

    add_action( ‘genesis_meta’, ‘minimumFRC_tourney_genesis_meta’ );

    /**

     * Add widget support for tourney page.

     *

     */

    function minimumFRC_tourney_genesis_meta() {

            if ( is_active_sidebar( ‘tourney-featured-left’ ) || is_active_sidebar( ‘tourney-featured-right’ ) ) {

                    add_action( ‘genesis_after_header’, ‘minimumFRC_tourney_loop_helper’ );

            }

    }

     

    to this in my file:

    /**
    * Add widget support for tourney page.
    *
    */

    add_action( ‘genesis_meta’, ‘minimumFRC_tourney_genesis_meta’ );

    function minimumFRC_tourney_genesis_meta() {

    if ( is_active_sidebar( ‘tourney-featured-left’ ) || is_active_sidebar( ‘tourney-featured-right’ ) ) {

    add_action( ‘genesis_after_header’, ‘minimumFRC_tourney_loop_helper’ );

    }
    }

    So the comment comes before both the action and the function.

    For some reason the breadcrumbs are still on the page, even though there’s a remove action that says it’s not supposed to be there, but I am NOT going to quibble.

    Goodnight, Michael, Brad and Bill!


    Be it ever so run down, there’s no place like FriendFeed. ;-)

    #26104

    Bill Murray
    Participant
    Post count: 575

    @BennetGlobal – Your problem is caused by some glitches at the top of your page template. Here’s the way it should read:

    [php]
    <?php
    /*
    Template Name: Entertainment
    */

    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );
    add_action( ‘genesis_loop’, ‘magazine_entertainment_loop_helper’ );
    /**
    * Add widget support for entertainmentpage. If no widgets active, display the default loop.
    *
    */
    [/php]

    Note that the template name is on its own line. The code on your pastebin link has an * on the line with the template name.

    I tested the modified code and it doesn’t generate errors, but that’s not to say it will do what you want. I don’t have sidebars with those ID’s, so that’s a little more work :)


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

Viewing 15 posts - 1 through 15 (of 26 total)

You must be logged in to reply to this topic.