Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #521688

    Hi there. I’ve been playing around with the “ava_after_main_container” action to insert a full width slider before the content on a site. See the private image link below. The problem is that it seems that the full width slider adds tags to close/open divs in the main part of the page so that inserting it with this action breaks the page layout. Is there any way I can do this without breaking the layout? Is there another action I can hook into that happens later on the page but before any of the page content (including the title and breadcrumb) has been rendered? I haven’t been able to find one.

    Thanks!

    #521942

    Hey Kevin!

    No, it will do the same wherever you use it. I’m guessing your using do_shortcode() ? It would be best to just edit your pages manually and add the slider in that way.

    I suppose you could try to fix the layout yourself by adding in extra tags but it’s pretty complex and I don’t know of the exact HTML you need.

    $output .= do_shortcode();
    $output .= '</div><div>';
    

    Regards,
    Elliott

    #522042

    Alright, so I got this working in a sort of unconventional way. I really wish there was a cleaner way to do this so it was more future proof but it’s working and that’s what counts. :-)

    Elliott said: I’m guessing your using do_shortcode() ? It would be best to just edit your pages manually and add the slider in that way.

    The problem with inserting it into the body is that Enfold doesn’t (apparently/frustratingly) have any hooks for inserting stuff before the content on a page. So if I insert it manually, I have to do it (manually) on every page. Even then it won’t display above the title.

    I sort of ended up using do_shortcode(). But I want my client to be able to edit the slider and the full width slider isn’t really available as a shortcode outside the layout builder. So, I created a post type called a “snippet” and built the slider inside one of those. Then I used a shortcode to insert the contents of the snippet on the “ava_after_main_container” action. The slideshow code is preceded by the following code that was breaking the layout:

    </div></div></div><!-- close content main div --></div></div>

    If this wasn’t there, apparently, the slider and the page would display normally. So I ended up doing this:

    add_action( 'ava_after_main_container', 'pwm_after_main_container', 10, 2 );
    function pwm_after_main_container(){
    	if( is_super_admin() && !is_front_page() ):
    
    		// get the contents of the snippet using my shortcode
    		$output = do_shortcode( "[pwm_snippet snippet_id='299' title_tag='h3' custom_class='']" );
    
    		// this is the stuff I need to get rid of
    		$stuff = "</div></div></div><!-- close content main div --></div></div>";
    
    		// $strip out the extra junk
    		$output = str_replace( $stuff, '', $output );
    
    		// output the results
    		echo $output;
    	endif;
    }

    Like I said, this isn’t a great solution but it seems to be working.

    Please add more hooks inside/outside the opening/closing tags for major sections. :-)

    Thanks!

    #522184

    Hey!

    Thank you for sharing your solution. We’ll notify Kriesi regarding this. An extra filter should be pretty handy if you want to add full width elements in the page.

    Cheers!
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.