Forums

[resolved] [Theme: Twenty Eleven] How to set Dark and White Color Skeme in specific pages (13 posts)

  1. johann64
    Member
    Posted 4 months ago #

    I'm preparing my wordpress website using Twenty Eleven child Theme and I need to set the Dark Color Skeme in some pages and the White Color Skeme in other pages.
    I tryed including all the "dark.css" styles (i found this file in the parent theme) in my child style.css file adding a new class ".darkclass" to all styles. Then i added this conditional tag in the body of the header.php child file:

    <body <?php if ( is_page(array( 18, 21, 34, 14, ))) {
    echo ' class="darkclass" '; } ?>
    <?php body_class(); ?>>
    but it doesn't work properly:
    1) the body background colour doesn't change in the interested pages,
    2) if i used a standard page structure in the interested pages it becomes a sidebar structure,
    3) the text color in interested pages is a dark gray (not white).
    Someone can help me?
    (sorry for my bad english)

    http://wordpress.org/extend/themes/twentyeleven/

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 months ago #

    Try:

    <body <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = ' class="darkclass" ';
    else $myclass = '';
    <?php body_class($myclass); ?>>
  3. johann64
    Member
    Posted 4 months ago #

    Dreamweaver tells me there is a syntax error in that code...
    I'm not a php expert :(

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 months ago #

    <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = ' class="darkclass" ';
    else $myclass = '';
    <?php body_class( $myclass ); ?>
  5. johann64
    Member
    Posted 4 months ago #

    still error... perhaps it lacks a php tag closure "?>"
    i tryed that:

    <body <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = ' class="darkclass" ';
    else $myclass = ''; ?>
    <?php body_class( $myclass ); ?>>

    it's without syntax error but the result it's no changes in all pages :-)

  6. esmi
    Theme Diva & Forum Moderator
    Posted 4 months ago #

    <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = ' class="darkclass" ';
    else $myclass = '';
    body_class( $myclass ); ?>

    Sorry - suffering post-migraine "cotton wool for brains" syndrome.

  7. johann64
    Member
    Posted 4 months ago #

    don't worry,
    the syntax now it's correct but it still doesn't work: no changes :-(
    Perhaps the problem is another, I thank you the same.

  8. alchymyth
    The Sweeper
    Posted 4 months ago #

    <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = 'darkclass';
    else $myclass = '';
    body_class( $myclass ); ?>

    http://codex.wordpress.org/Function_Reference/body_class

    or more complicated, add something like this to functions.php of your child theme:

    remove_action( 'wp_enqueue_scripts', 'twentyeleven_enqueue_color_scheme' );
    function dark_pages_enqueue_color_scheme() {
    
    	if ( is_page(array( 18, 21, 34, 14 )) )
    		wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), null );
    }
    add_action( 'wp_enqueue_scripts', 'dark_pages_enqueue_color_scheme' );

    (not widely tested)

  9. johann64
    Member
    Posted 3 months ago #

    thank you very much alchymyth!!!!
    the 2nd solution (changing function.php child theme file) work properly, now I need to set a different background image in the dark color scheme.
    I tryed to set this option in the style.css (child theme) file:

    .darkclass body.custom-background {
        background-attachment: scroll;
        background-image: url("http://127.0.0.1/~gianni/wpgianni2/wp-content/uploads/2012/02/FondoIcona1.jpg");
        background-position: left top;
        background-repeat: no-repeat;
    }

    but it doesn't change and remains the same setted in the white color scheme.
    Can I have a help?

  10. alchymyth
    The Sweeper
    Posted 3 months ago #

    Twenty Eleven doesn't make customisation easy ;-)

    next step:

    http://www.transformationpowertools.com/wordpress/twenty-eleven-overwrite-dark-color-scheme-in-child-theme

    also:
    where is that class coming from: .darkclass
    and, are you sure that the css syntax is right?

    imho, it should be: body.darkclass.custom-background { }

    can you post a link to your site to illustrate what you have so far?

  11. johann64
    Member
    Posted 3 months ago #

    a clarification:
    I mean that only the IMAGE doesn't change in the dark color scheme.

    I left in header.php (child theme) the code to activate the class .darkclass

    <?php if ( is_page(array( 18, 21, 34, 14, ))) $myclass = 'darkclass';
    else $myclass = '';
    body_class( $myclass ); ?>

    thank you in advance

  12. alchymyth
    The Sweeper
    Posted 3 months ago #

    have you tried to work with this css:

    body.darkclass.custom-background {
        background-attachment: scroll;
        background-image: url("http://127.0.0.1/~gianni/wpgianni2/wp-content/uploads/2012/02/FondoIcona1.jpg");
        background-position: left top;
        background-repeat: no-repeat;
    }

    or

    body.custom-background.darkclass { ... }
  13. johann64
    Member
    Posted 3 months ago #

    thank you alchymyth!!!! you are great!!!!
    the css syntax was bad, i changed it how you wrote and now it work all properly!!!!!
    If you come in Italy to visit Venice you'll be my guest to the restaurant for a dinner!

Reply

You must log in to post.

About this Topic