views:

105

answers:

1

First of all, my question may be unclear. I will try to explain it.

this is my html

<div class="left"><?php print $search_box; ?><?php if (!empty($logo)): ?><a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home"><img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" id="logo" width="243" height="62" /></a><?php endif; ?><?php if (!empty($site_name)): ?><div id='site-name'><strong><a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home"><?php print $site_name; ?></a></strong></div><?php endif; ?><?php if (!empty($site_slogan)): ?><div id='site-slogan'><?php print $site_slogan; ?></div><?php endif; ?></div>

looks ugly and difficult to debug, right?

so i try to indent and add newline. However, it will fails on some browser, may be IE6. The result is changed. So, What should i go, should i use another doctype?

Currently, i am using

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
+1  A: 

You can write it this way too:

<div class="left">
  <?php print $search_box; ?>
    <?php if (!empty($logo)) { ?>
    <a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home">
      <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" id="logo" width="243" height="62" />
    </a>
  <?php } ?>

  <?php if (!empty($site_name)) { ?>
    <div id='site-name'>
      <strong>
      <a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home"><?php print $site_name; ?></a>
      </strong>
    </div>
  <?php } ?>

  <?php if (!empty($site_slogan)) { ?>
    <div id='site-slogan'><?php print $site_slogan; ?></div>
  <?php } ?>
</div>

This should work in most cases, or you can use the php heredoc syntax to echo out the html stuff normally.

Sarfraz
um... are you sure replacing : with { solve the problem??Actually i want to do exactly what u wrote. however, IE will change the output, because there is extra #text nodes inside the tags.new browser don't have this problem.
Tommy
or you may try using the heredoc syntax of php, see my answer again. thanks
Sarfraz
My IE6 VM is dead, so i cannot test this. but heredoc is great, thanks for the help.
Tommy
you are always welcomed, thanks
Sarfraz