Community Forums › Forums › Archived Forums › General Discussion › Create New Page Template
Tagged: custom layouts, Page Templates, widget areas
- This topic has 25 replies, 5 voices, and was last updated 11 years, 7 months ago by marybaum.
-
AuthorPosts
-
March 11, 2013 at 12:36 pm #25486BennettGlobalMember
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
March 11, 2013 at 10:05 pm #25571Brad DaltonParticipantI 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
March 13, 2013 at 11:34 am #25887marybaumParticipantI'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
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 12:15 pm #25898stacyvlasitsMemberMary, 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 )March 13, 2013 at 1:42 pm #25924marybaumParticipantSounds like I should take it out of the template above. Thanks! I'll try that.
MB
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 4:27 pm #26059marybaumParticipantDidn'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.
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 4:59 pm #26072BennettGlobalMemberI'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...
March 13, 2013 at 5:27 pm #26077marybaumParticipantSince 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
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 6:33 pm #26081BennettGlobalMemberHi 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...
March 13, 2013 at 6:34 pm #26082Bill MurrayMember@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.
March 13, 2013 at 7:02 pm #26088marybaumParticipantOkay - 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.
MB
Relevant functions:
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 7:15 pm #26090BennettGlobalMemberHi Bill,
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)
March 13, 2013 at 7:50 pm #26092Brad DaltonParticipantI'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
March 13, 2013 at 8:39 pm #26102marybaumParticipantWell. 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!
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 8:49 pm #26104Bill MurrayMember@BennetGlobal - Your problem is caused by some glitches at the top of your page template. Here's the way it should read:
<?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. * */
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.
March 13, 2013 at 9:22 pm #26115Bill MurrayMember@marybaum - There's no PHP errors in the code you posted in the pastebin; it runs fine for me. However, note that on line 24 you are removing the loop. If you do that, you won't display any page content.
I just now read your comment that the code works, but I don't see a difference between what you posted here and what you posted on pastebin. As long as your comments are opened and closed properly, their location doesn't matter.
For your breadcrumb issue, your remove action is wrong. Change it to:
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
For both, whenever you get parse errors or PHP errors, they have nothing to do with your CSS. You can specify ID's and classes in your PHP code that don't exist, and that won't produce an error. To get a PHP error, your code has some basic flaw - such as a typo, an unclosed () or { }, a missing ; at the end of a line.
Hope that helps.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
March 13, 2013 at 9:43 pm #26119BennettGlobalMemberHey Bill,
That one change did not work, I still get the error code, but after reading your tutorial code its identical to what I want to do other than the name. I think I'm going to give it a try.
Michael
March 13, 2013 at 9:55 pm #26120Bill MurrayMember@BennetGlobal - I didn't post a tutorial; I think that was in Brad's post.
One other thought is that your text editor is inserting something on line 12 because of its length. You might want to check out PHP editors, such as Notepad++. Other than the glitch I commented on, there's nothing in the code that would generate an error.
You can test that theory by temporarily replacing line 12 with:
if ( is_active_sidebar( 'entertainment-top' )) {
It will have the same impact as long as you put a widget in that widget area.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
March 13, 2013 at 10:00 pm #26121marybaumParticipantThanks, Bill! It does work.
I'll change the breadcrumb-remove - though I think I may want to keep it. Only problem is that having removed all the content, it shows up below my widgets, and I'm not clear from looking at the hook reference which one would get it above them. Did I miss a before_wrap hook? Can I invent hooks? Like before_featured_area?
Thanks again for looking at the code!
Michael, looking forward to the end of your magazine journey.
Night all . . . I'll check in in the morning.
Mary
Sharing the good news about the wonders of modern CSS and the split-step. Either one should get you moving fast. 😀
March 13, 2013 at 10:18 pm #26125Bill MurrayMember@marybaum - No, unfortunately you can't invent hooks - unless you want to take the time to write the code to make them work, which would really involve modifying Genesis, which you shouldn't do. I think you want to change where you add your custom function:
add_action( 'genesis_meta', 'minimumFRC_tourney_genesis_meta' );
You're adding them in genesis_meta, and that's way too soon. That's why they appear before your header. Try a hook that comes later. A really quick guess is genesis_after_content, but I'm not sure how that will work since you removed the loop.
One note on hooks: you always have to look at your child theme to see if it has relocated something that is normally in 1 place and put it in another. For example, if nav menus are normally below the header, but the child theme has relocated them to before the header, and you use a remove action from a tutorial that assumes the normal placement, it won't work - because the nav menus aren't in the place expected by the tutorial author. That's especially true since your functions.php gets executed before your page template.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.