Page 1 of 1

if statement not working in IE8

Posted: Sat Jan 23, 2010 1:35 am
by sc0tt
Only in IE8, the presence of the following if statement results in no image being displayed, even though the page source is identical in FF, Chrome and IE8. <?php if (!$page) { ?>href="<?php print $node_url?>"><?php }. The if statement simply prevents the href statement from being added if we are in node view. If I remove the if statement, the image appears as expected.

Here is the complete php code folowed by idendical page source from FF and IE8:
<a <?php if (!$page) { ?>href="<?php print $node_url?>"><?php } print theme('imagecache', $field_inline_1_image_width[0]['value'], $field_inline_1_image[0]['filepath'], $node->title, '', array('style' => 'border:'.$field_inline_1_image_border[0]['value'].'px solid #bbb')); ?></a>

FF page source:
<a <img src="http://www.newsite.fillmoregazette.com/ ... 0-1648.jpg" alt="test from editor joe" title="" style="border:1px solid #bbb" width="640" height="480" /></a>

IE8 page source:
<a <img src="http://www.newsite.fillmoregazette.com/ ... 0-1648.jpg" alt="test from editor joe" title="" style="border:1px solid #bbb" width="640" height="480" /></a>

Anyone have a clue as to why the presence of the if statment causes the image to not be displayed in IE8?
Thank you,
Scott

Re: if statement not working in IE8

Posted: Sat Jan 23, 2010 2:15 am
by requinix
That's totally invalid HTML. Of course it won't behave as expected.

With a link:

Code: Select all

<a href="<?php print $node_url; ?>"><img src="http://www.newsite.fillmoregazette.com/sites/default/files/imagecache/640/images/2010/01/22/sports-test-editor-joe-22-01-2010-1648.jpg" alt="test from editor joe" title="" style="border:1px solid #bbb" width="640" height="480" /></a>
Without a link:

Code: Select all

<img src="http://www.newsite.fillmoregazette.com/sites/default/files/imagecache/640/images/2010/01/22/sports-test-editor-joe-22-01-2010-1648.jpg" alt="test from editor joe" title="" style="border:1px solid #bbb" width="640" height="480" />

Re: if statement not working in IE8

Posted: Sat Jan 23, 2010 3:09 am
by sc0tt
Thanks for the commentary. Can you recomend a solution? Also, where are you getting the following? It's not from my original post and is invalid.

1. <a href="<?php print $node_url; ?>"><img src="http://www.newsite.fillmoregazette.com/ ... 0-1648.jpg" alt="test from editor joe" title="" style="border:1px solid #bbb" width="640" height="480" /></a>

Thank you,
Scott

Re: if statement not working in IE8

Posted: Sat Jan 23, 2010 3:17 am
by requinix
sc0tt wrote:Thanks for the commentary. Can you recomend a solution? Also, where are you getting the following? It's not from my original post and is invalid.
What I posted was a partial solution. It should be enough for you to figure out what you have to change.

Re: if statement not working in IE8

Posted: Sat Jan 23, 2010 5:06 am
by MichaelR
Try this:

Code: Select all

$image = theme('imagecache', $field_inline_1_image_width[0]['value'], $field_inline_1_image[0]['filepath'], $node->title, '', array('style' => 'border:'.$field_inline_1_image_border[0]['value'].'px solid #bbb'));
 
if (!$page) {
  $image = '<a href="' . $node_url . '">' . $image . '</a>';
}
 
print $image;
 

Re: if statement not working in IE8

Posted: Sat Jan 23, 2010 4:10 pm
by sc0tt
Thank you!
Worked perfectly and very fast!
Scott

PS. Can I buy you lunch?

PSS. Is there any way to support this board financially?