StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Adding Widget Area to a Single Page (http://www.studiopress.com/support/showthread.php?t=120776)

NandoJourneyman 10-13-2012 05:34 PM

Adding Widget Area to a Single Page
 
I keep messing this up, so I figured I'd ask.

Here's what I'm trying to do: I want to have a page that shows the page content, as the page template normally would. Right after the content, there will be a widget area. While I imagine just about any widget could be used here, I intend to use the Genesis Responsive slider to show and scroll through several subpages' worth of content without having to navigate to them.

Ideally, this will be a full width page (no sidebars).

I can't seem to get a custom template to work for this. :bang:

Help? Pretty please?

andrea_r 10-13-2012 06:06 PM

Related to your other post - this is the part where you;d use the eleven40 widget tute to add the widget area with a hook. ;)

Or... if you made a new page template, add the widget area right in the template. Can also use a hook here.


http://www.studiopress.com/tutorials/hooks
http://www.studiopress.com/tutorials/hook-reference
http://genesistutorials.com/visual-hook-guide

NandoJourneyman 10-15-2012 09:22 AM

Eureka!
 
I got it. Well, it works, but I figured I post the code here for someone else's benefit, as well as your vetting for whatever code compliances and compatibilities I may have missed :razz:

Here's the template (I called mine page_widgetized.php):

Code:

<?php
/*
Template Name: Widgetized Page
*/

/** Optional -Forces the full width layout on the Portfolio page */
/** add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); */

/** Optional -Removes the standard loop */
/** remove_action( 'genesis_loop', 'genesis_do_loop' ); */

/** This adds the widgetized area */
add_action( 'genesis_after_post_content', 'widgetized_page_area_sidebar' );

/** This should put a widget area right after the content*/
function widgetized_page_area_sidebar() {
    echo '<div class="widgetized-area-style">';
            dynamic_sidebar( 'widgetized-page-area' );
    echo '</div>';
}

genesis();


Of course, this need to be registered in functions.php :

Code:

/** Register Widgetized Page Area widget */
genesis_register_sidebar( array(
    'id'        => 'widgetized-page-area',
    'name'      => 'Widgetized Page Area',
    'description'  => 'This is the widgetized page area sidebar.',
) );


It's been assigned a class, so that the CSS is (with whatever width value works for user):

Code:

/* Widgetized Area style
--------------------------------- */
.widgetized-area-style {
    clear: both;
    margin: 0 auto;
    width: 728px;
}

Not too bad huh?

andrea_r 10-15-2012 09:23 AM

:clap: Pretty snazzy - move to the head of the class. ;)


All times are GMT -5. The time now is 11:19 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.