www.webdeveloper.com
Results 1 to 9 of 9

Thread: Wierd ie6 problem with "if else" statement

  1. #1
    Join Date
    Sep 2008
    Posts
    25

    Wierd ie6 problem with "if else" statement

    Hi, is it just me who has stared my self blind on some little problem or why isnt this working correctly. Im trying to show different content on my wordpress pages with the if else statement, which works perfectly fine in firefox, but somehow it seems my ie6 doesent understand not to include the sidebar on my front page. This is my code:
    Code:
    <?php get_header(); ?>
    	<div id="content" class="widecolumn">
    
    <?php /* XXXXXXXXXXXXXXXX THIS CODE DISPLAYS THE TEXT THAT IS WRITTEN ON THE "PAGES" XXXXXXXXXXXXXXXXXXXXXXXXXX */ ?>
    <?php if ( is_front_page() ) { ?> 
    
    <p>lol</p> 
    
    <?php  } else { ?>
    
    <div class="leftblock">
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>
    
    
    <?php /* php get_sidebar(); */ ?>
    <div id="sidebar">
    <ul>
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('sidebar1') ) : ?>
    <?php endif; ?>
    </ul>
    </div>
    <?php } ?>
    Can you figgure out what i have done wrong? :S

    Thank you very much!

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    PHP is executed on the server before anything is sent to the browser so it's unlikely to be a PHP issue. I'd take a look at the generated HTML and the related CSS, that's the usual culprit with IE woes.

  3. #3
    Join Date
    Sep 2008
    Posts
    25
    ok, i have tried that but i cant figgure it out, the website is http://mayslesinstitute.org/blog

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,529
    Since the PHP code is run on the server and not on the browser; if you are getting a different result on different browsers, then my first guess is that it's simply a case of the browser displaying a cached page. This might be solved simply by doing a page refresh in the browser. If that's not the case, then the only other thing I can think of based on the limited info at hand is that there is something in the code we're not seeing that is dependent upon something sent (or not sent) by the browser. (For instance, what does the is_front_page() function do?)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Sep 2008
    Posts
    25
    is a wordpress statement that listents for weather it is the "page" called frontpage.

    The thing im seeing now, because i also used the same "if else" in the header that loads the content of the "imgheader" div is also different in the two browsers.

  6. #6
    Join Date
    Sep 2008
    Posts
    25
    but just to be sure, ie6 and firefox and all other browsers for that matter, reads php exactly the same right?

  7. #7
    Join Date
    Nov 2008
    Posts
    2,477
    It's not a case of a browser reading php, the browser has no knowledge of php at all. All php code is run on the server and the result (usually some (X)HTML as in this case) is sent to the browser. Whatever the browser, it gets the exact same thing from the server as every other browser (usually, but lets not go there ).

  8. #8
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,529
    Browsers do not read PHP at all. All the PHP processing gets done on the server, and all any browser sees are the results of whatever the server processes and sends to the client (browser).

    If two browsers are showing different results for the exact same page request from the same host, then either there is something about the [X]HTML being output to them that is either invalid (causing each browser to make its best guess at what to do or else ignore it) or at least one of them is displaying a result from a cached page it retrieved before you made your more recent changes. A third but probably less likely situation in this case is that some part of your script depends upon something sent in one of the HTTP request headers sent by the browser and is causing some different logical path to be followed. This could possibly be the case if some part of the PHP script depends on a $_SERVER['HTTP_<something>'] value.

    I would therefore first try clearing each browser's cache to see if that clears things up. If not, do a "view source" on each to see if they are both getting the same exact output. and perhaps run that output through the HTML validator and then CSS validator to see if perhaps some invalid mark-up is confusing the browsers.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  9. #9
    Join Date
    Sep 2008
    Posts
    25
    Problem solved!
    I found out today that the fact that i had chosen a static homepage for the wordpress template and then chosen not to publish that page (so it wouldnt show in my menu) caused wordpress to sometimes grab the right page, and firefox would then cache it, and other times wordpress wouldnt catch the right page which caused the different pages showing up!
    lol, but when i chosed to make that static page in wordpress "public" everything worked out.
    Thanks for your help guys!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles