I was trying to figure out why my linked site name was indented and spent a little time looking at this part of the page.tpl.php file:

  <div id="page" class="container-16 clear-block">

    <div id="site-header" class="clear-block">
      <div id="branding" class="grid-4 clear-block">
      <?php if ($linked_logo_img): ?>
        <span id="logo" class="grid-1 alpha"><?php print $linked_logo_img; ?></span>
      <?php endif; ?>
      <?php if ($linked_site_name): ?>
        <h1 id="site-name" class="grid-3 "><?php print $linked_site_name; ?></h1>
      <?php endif; ?>
      <?php if ($site_slogan): ?>
        <div id="site-slogan" class="grid-3 omega"><?php print $site_slogan; ?></div>
      <?php endif; ?>
      </div>

The whole logic for assigning the alpha and omega tags seems screwy since it doesn't know if the previous element was output. The linked_site_name should always be output since it's a required field but the linked_logo_img and site_slogan are not.

This bit seems to do the trick for me but it's kind of klunky:

        <h1 id="site-name" class="grid-3 <?php print ($linked_logo_img ? '' : 'alpha ') . ($site_slogan ? '' : ' omega'); ?>"><?php print $linked_site_name; ?></h1>

Comments

dvessel’s picture

Eh, yeah.. That definitely needs improving. I'll see if there's a cleaner way.

rok@luckypressure.com’s picture

What about a simple "switch" statement?

There is 4 cases:

logo+title+slogan > logo has class "alpha" & slogan has class "omega".
logo+title >logo has class "alpha" & title has class "omega".
title
title+slogan >title has "alpha" & slogan has "omega".

I should learn how to write this simple stuff in php and how to create a patch...

dvessel’s picture

Status: Needs work » Fixed

I'll have an upcoming patch that simplifies it but it's won't be specific to this. It will look like this:

    <div id="branding" class="grid-4">
    <?php if ($logo_img || $site_name): ?>
      <h1 id="brand-id">
        <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home">
          <?php print $logo_img; ?>
          <?php if ($site_name): ?><span class="site-name"><?php print $site_name; ?></span><?php endif; ?>
        </a>
      </h1>
    <?php endif ?>
    <?php if ($site_slogan): ?>
      <div id="site-slogan"><?php print $site_slogan; ?></div>
    <?php endif; ?>
    </div>

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.