ThemeShaper Forums » Thematic

[closed]

Left margin dropped in IE when modify Header.php

(9 posts)
  • Started 3 years ago by soren
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Hello!

    Don't know what is going wrong here... I use this following code (below the blackhole) in Header.php from "Digging Into WordPress". What happen is that in Internet Explorer the left margin is dropped but in FireFox and Safari there is no problem. I tried with <head> as a start but that did not help...

    Any solution that can help?

    Thanks

    '
    <?php include($_SERVER['DOCUMENT_ROOT'] . "/blackhole/blackhole.php"); ?>

    <?php if(is_home() && (!$paged || $paged == 1) || is_single()) { ?>
    <meta name="googlebot" content="index,archive,follow,noodp" />
    <meta name="robots" content="all,index,follow" />
    <meta name="msnbot" content="all,index,follow" />
    <?php } else {?>
    <meta name="googlebot" content="noindex,noarchive,follow,noodp" />
    <meta name="robots" content="noindex,follow" />
    <meta name="msnbot" content="noindex,follow" />
    <?php } ?>

    <?php

    // Creating the doctype
    thematic_create_doctype();
    echo " ";
    language_attributes();
    echo ">\n";

    // Creating the head profile
    thematic_head_profile();

    // Creating the doc title
    thematic_doctitle();

    // Creating the content type
    thematic_create_contenttype();

    // Creating the description
    thematic_show_description();

    // Creating the robots tags
    thematic_show_robots();

    // Creating the canonical URL
    thematic_canonical_url();

    // Loading the stylesheet
    thematic_create_stylesheet();

    if (THEMATIC_COMPATIBLE_FEEDLINKS) {
    // Creating the internal RSS links
    thematic_show_rss();

    // Creating the comments RSS links
    thematic_show_commentsrss();
    }

    // Creating the pingback adress
    thematic_show_pingback();

    // Enables comment threading
    thematic_show_commentreply();

    // Calling WordPress' header action hook
    wp_head();

    ?>

    </head>

    <?php

    thematic_body();

    // action hook for placing content before opening #wrapper
    thematic_before();

    if (apply_filters('thematic_open_wrapper', true)) {
    echo '<div id="wrapper" class="hfeed">';
    }

    // action hook for placing content above the theme header
    thematic_aboveheader();

    ?>

    <div id="header">

    <?php

    // action hook creating the theme header
    thematic_header();

    ?>

    </div><!-- #header-->
    <?php

    // action hook for placing content below the theme header
    thematic_belowheader();

    ?>
    <div id="main">

    '

    Posted 3 years ago #
  2. why are you modifying header.php? what changes did you make?

    Posted 3 years ago #
  3. @helgatheviking

    The only thing I added was this

    <?php if(is_home() && (!$paged || $paged == 1) || is_single()) { ?>
    <meta name="googlebot" content="index,archive,follow,noodp" />
    <meta name="robots" content="all,index,follow" />
    <meta name="msnbot" content="all,index,follow" />
    <?php } else {?>
    <meta name="googlebot" content="noindex,noarchive,follow,noodp" />
    <meta name="robots" content="noindex,follow" />
    <meta name="msnbot" content="noindex,follow" />
    <?php } ?>

    When I remove this lines from the Header.php... IE works fine and has a left margin but when adding this IE dropps the left margin. I don't know why as both Firefox and Safari has no problem...!
    I use this method to prevent duplicate content recommended by "Diggin Into WordPress" by Chris Coyier and Jeff Starr

    Thanks

    Posted 3 years ago #
  4. middlesister
    Member

    You have added your code above everything else - even before the doctype declaration. This means the webpage hasn't even started yet when your code is executed.

    But there really is no need for you to modify header.php, you can add code to <head> with a hook instead. And in your case, thematic is already adding similar meta robots rules. If you want to change them, you can filter thematic_create_robots.

    function childtheme_create_robots($content) {
    	global $paged;
    	$content = "\t";
    	if(is_home() && (!$paged || $paged == 1) || is_single()) {
    		$content .= "<meta name="googlebot" content="index,archive,follow,noodp" />";
    		$content .= "<meta name="robots" content="all,index,follow" />";
    		$content .= "<meta name="msnbot" content="all,index,follow" />";
        } else {
    		$content .= "<meta name="googlebot" content="noindex,noarchive,follow,noodp" />";
    		$content .= "<meta name="robots" content="noindex,follow" />";
    		$content .= "<meta name="msnbot" content="noindex,follow" />";
        }
    	$content .= "\n\n";
    	return $content;
    }
    add_filter('thematic_create_robots','childtheme_create_robots');

    Put this code in your functions.php. It is best to leave header.php alone.

    Posted 3 years ago #
  5. yay!! +1 for middlesister. really great to see someone else answering questions as that helps the community grow.

    Posted 3 years ago #
  6. middlesister. thank you for helping. It was recommended to put this lines in header.php. I did try your solution in functions.php and it actually got worse :( I got http500 error when using IE, did not show the page at all... and Safari and Firefox did not have this problem...perhaps the cache file is playing with me...

    Anyway if thematic already adding this robots rules then it should be fine and I leave it that way...

    Thanks

    Posted 3 years ago #
  7. @soren, you can add things to header.php via thematic's hook à la the method demo'd by middlesister. haven't tried it but there could be a typo error or something... that sometimes happens to me.

    throwing it into my testing environment- the problem was w/ the way the quotes were being used. this doesn't break anything for me, but i'm not sure the conditional logic is doing exactly what you want... but you can hopefully figure that out.

    function childtheme_create_robots($content) {
    	global $paged;
    	$content = "\t";
    	if(is_home() && (!$paged || $paged == 1) || is_single()) {
    		$content .= '<meta name="googlebot" content="index,archive,follow,noodp" />';
    		$content .= '<meta name="robots" content="all,index,follow" />';
    		$content .= '<meta name="msnbot" content="all,index,follow" />';
        } else {
    		$content .= '<meta name="googlebot" content="noindex,noarchive,follow,noodp" />';
    		$content .= '<meta name="robots" content="noindex,follow" />';
    		$content .= '<meta name="msnbot" content="noindex,follow" />';
        }
    	$content .= "\n\n";
    	return $content;
    }
    add_filter('thematic_create_robots','childtheme_create_robots');

    the main point is that we prefer to add things via hook/filter versus adding things to header.php or even copying header.php into our child's folder.

    Posted 3 years ago #
  8. middlesister
    Member

    Thanks helga.
    I should probably start to pre-write any code snippets in my text editor to take advantage of syntax highlighting - that would avoid typos like these.
    Not much help if the code doesn't work, right? :)

    Posted 3 years ago #
  9. haha... well yeah, but i do it all the time too. when i am feeling particularly generous i drop it into whatever theme i current have running in the background. that is the best way, but plenty of times i just write from memory- which often leads to slightly mangled syntax... like a semi-colon running amuck

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.