Consolidate Home Featured Areas (Min Pro)

Community Forums Forums General Discussion Consolidate Home Featured Areas (Min Pro)

This topic is: resolved

This topic contains 7 replies, has 2 voices, and was last updated by  nutsandbolts 9 months, 4 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #77094

    Nathaniel
    Member
    Post count: 18

    Visually: my goal is to replace the home featured widgets (1 – 4) in Minimum Pro with a Genesis Responsive Slider. I realize that, in terms of code, it might be simpler to leave the home featured widgets alone (and empty) and simply create a new widget area. Or maybe I should delete home featured widgets 2 – 3 and then resize home featured widget 1 so that it’s full-width?

    I don’t know.

    Could someone please advise me?

    Thanks!

    http://drtest.nathanielgivens.com/
    #77102

    nutsandbolts
    Moderator
    Post count: 3131

    I think it would definitely be easier to add a new widget area. You can always leave 1-4 empty if you don’t plan to use them.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #77361

    Nathaniel
    Member
    Post count: 18

    Thanks, Andrea. I’m going to try and do that, but I have to admit that I don’t actually know how. I’ve never added a widget area to this theme (or any theme), and I can’t find any tutorials online that address my goal.

    Do you have any pointers?

    #77370

    Nathaniel
    Member
    Post count: 18

    Andrea (or anyone else), this is my understanding of what I can do to add a new widget area beneath the home-featured widget areas. I’m going to explain what I plan on doing and why, and I would really appreciate any guidance. I’m going to wait to get feedback before I started editing my files. (Of course I have backups, but I don’t even know if I’m on the right track and I don’t want to start blundering around.)

    Step 1: Create a container for the new widget area and also the new widget area in style.css

    I just copied the existing code for .home-featured (which is a site container that holds all 4 of the home-featured widget areas) and renamed it .home-slider-container (instead of .home-featured)

    .home-slider-container{
    	border-bottom: 5px solid #f5f5f5;
    	margin-bottom: 60px;
    	margin-bottom: 6rem;
    	padding: 40px 0;
    	padding: 4rem 0;
    }

    Then I also added the site container that is the actual home-slider widget area. This is based on the .home-featured-1 site container. Only change: I made the width 100% instead of 25%.

    .home-slider{
    	float: left;
    	text-align: center;
    	width: 100%;
    }

    Step 2: Modify the front-page.php file to get these containers to actually show up on the front page.

    So I was planning on inserting this right after the section that begins with the commend

    //* Add markup for homepage widgets section

    That’s because–and this is a wild guess–I think that maybe the order of the stuff in front_page.php shows what order (vertically) they show up on the screen? I don’t know. In any case, this is the code I was going to add:

    //* Add markup for homepage slider
    function minimum_home_slider_container() {
    
    	printf( '<div %s>', genesis_attr( 'home-slider' ) );
    	genesis_structural_wrap( 'home-slider-container' );
    
    		genesis_widget_area( 'home-slider', array(
    			'before' => '<div class="home-slider widget-area">',
    			'after'	 => '</div>',
    		) );
    
    	genesis_structural_wrap( 'home-slider', 'close' );
    	echo '</div>'; //* end .home-slider
    
    }

    3. Register the widget in functions.php

    So the last step is to go to the comment

    //* Register widget areas

    Where there’s a list of widgets (like the home-featured-1, home-featured-2, etc.) and, at the end, tack on this code:

    genesis_register_sidebar( array(
    	'id'          => 'home-slider',
    	'name'        => __( 'Home Slider', 'minimum' ),
    	'description' => __( 'This is the home slider section.', 'minimum' ),
    ) );

    I would really appreciate any feedback that tells me if I’m on the right track of not. Thank!

    #77377

    Nathaniel
    Member
    Post count: 18

    Oh, maybe I also need to add this to the functions.php file?

    //* Add support for structural wraps
    add_theme_support( 'genesis-structural-wraps', array(
    	'header',
    	'site-tagline',
    	'nav',
    	'subnav',
    	'home-featured',
            'home-slider-container' //* added this line
    	'site-inner',
    	'footer-widgets',
    	'footer'
    ) );

    Anything else?

    #77414

    nutsandbolts
    Moderator
    Post count: 3131

    It looks like you’re on the right track. You actually probably don’t need the container since there’s only one widget area in it, but it shouldn’t hurt anything to have it there.

    I would try it out, making sure you have your CPanel file manager or FTP open in case functions.php breaks, and see how it goes. If you run into problems, post back to this thread and I’ll try my best to help.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #77486

    Nathaniel
    Member
    Post count: 18

    Thanks for your encouragement, Andrea! I went ahead and tried making the changes (exactly as outlined), and it turns out that there was one thing I had forgotten to do. I’m copy-pasting here in case anyone else comes along and is interested.

    Here’s the last piece of code I needed to add to get the widget to display properly:

    if ( is_active_sidebar( 'home-slider') ) {
    		//* Add Home-Slider Widget areas
    		add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_slider_container', 15);
    	}

    I needed to add this to front-page.php inside the function function minimum_front_page_genesis_meta(). I added it at the very end, and then my test text-widget displayed! I can’t believe how fast this actually ended up being. Now to see if I can get a slider to display correctly in that widget area…

    #77487

    nutsandbolts
    Moderator
    Post count: 3131

    Awesome! So glad you got it working. Be sure to keep a list of steps in a doc on your computer somewhere, because now that you know how to do it, the same method will work (for the most part) on any Genesis child theme. That’s what makes the framework great. :)


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.