Tagged: ,

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

    Hi,
    I’m trying to style pages which have a sidebar differently from those without sidebar.
    I couldn’t find a top level class to differenciate both kinds of pages, does Enfold do that ?
    If not, could you help me find a way to add a body class for pages with sidebar, I’m thinking for example of a “has_sidebar” body class for all pages with sidebar.
    Thanks

    #927284

    Hey mike235,
    For pages the sidebar class is under the ID #main and class .container_wrap
    So for example:

    #top #wrap_all #main .sidebar_right 

    add your target afterwards

    Best regards,
    Mike

    #927298

    Hi Mike,
    Here’s a real example, how would you style the H1 (class “main-title”) on a page without a sidebar, and on a page with a sidebar ?
    I haven’t found a way to do that, because AFAIK Enfold doesn’t add a higher level class (in body for example) which allows us to differentiate pages with and without sidebars.
    Thanks

    #927317

    Hi,
    Assuming that your default style for h1 is going to be your style for pages without a sidebar, then we will change the style when the
    left sidebar is is place:

    #top #wrap_all #main .sidebar_left h1 {color: red !important;}

    for either sidebar:

    #top #wrap_all #main .sidebar_left h1,#top #wrap_all #main .sidebar_right h1 {color: red !important;}

    On my test page the h1 was a special heading, so I prefer:

    #top #wrap_all #main .sidebar_left h1.av-special-heading-tag {color: red !important;}

    Best regards,
    Mike

    #927335

    Thanks for the quick reply. If we look at the source code :

    <div class='stretch_full container_wrap alternate_color light_bg_color title_container'>
    <div class='container'>
    <h1 class='main-title entry-title'>
    <a href='' rel='bookmark' title='Lien permanent : Évaluer'  itemprop="headline" >Évaluer</a>
    </h1>
    
    etc...
    
    <div class='container_wrap container_wrap_first main_color sidebar_right'>

    I’m trying to style the H1 with class main-title, the main title of the page, which is located before the sidebar_right class. So your code would only work for any H1 that is inside the container_wrap with the sidebar class.

    I guess I’ll just have to move the title code after the container wrap, but I’d have preferred not touch the templates..

    • This reply was modified 6 years, 9 months ago by mike235.
    #927742

    Hi,

    it would require unfortunately for that move that you said, as there is no easier way we are afraid.

    Best regards,
    Basilis

    #936650

    Hi,

    Here’s how I solved the problem, in case anybody else is interested.

    This adds a “entry_with_sidebar / entry_without_sidebar” class to the body tag :

    function mwm_add_body_classes( $classes ) {
        $avia_config['size'] = avia_layout_class( 'main' , false) == 'fullsize' ? 'entry_without_sidebar' : 'entry_with_sidebar';
        $classes[] = $avia_config['size'];
        return $classes;
    }
    add_filter( 'body_class', 'mwm_add_body_classes' );
    #936863

    Hi,

    Thank you for updating us and providing the class, we appreciate it a lot!

    Best regards,
    Basilis

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Body class for pages with sidebar’ is closed to new replies.