hey there,

first off, thanks for the theme ;) goes without saying but it's always nice to say.

it's great to see a Drupal project whose contributors actually encourage suggestions. kudos.

so here's mine: sticky footer. like this one or that one.

I've already implemented the first solution (kind of) here (it's in Portuguese, but oh well - sticky footer is an universal language). I think it can get better with the community push.

whattyasay?

cheers,
Luciano

Comments

luco’s picture

well, I figured this one out.

so here's the needed sticky_footer.tpl.php (changed so as the #footer DIV is outside the #page DIV) and a very useful sticky_footer.css.

to use it, simply copy sticky_footer.tpl.php as page.tpl.php and sticky_footer.css (without changing its name) into your zen subtheme folder. don't change the css filename, though, only the tpl.php filename.

find in your zen subtheme's .info file the line that reads:

stylesheets[print][] = print.css

and above it, write:

stylesheets[all][] = sticky_footer.css

reload your theme's registry by visiting admin/build/modules. voilà!

luco’s picture

StatusFileSize
new4.47 KB

forgot the attachment...

luco’s picture

StatusFileSize
new4.47 KB

well, I'll be darned. I have to reply again in order to attach the file.

scottrigby’s picture

@luco: great idea :)

It would have better success though if supplied as a patch.

Looking forward to seeing where this goes

luco’s picture

sorry. I can't create patches. the whole concept just goes right through me :)

if anyone can / has time to create a patch I'll happily talk to them.

KrisBulman’s picture

I've tried this, and it doesn't work.

luco’s picture

and by "doesn't work" you mean... ?

let's bounce some ideas, see what we can come up with.

luco’s picture

hey all,

I'm trying to add a sticky-footer.css file to Zen version 6.x-2.0-beta1, but it simply won't work. I went to zen.info, added "stylesheets[all][] = css/sticky-footer.css", cleared the caches... but nothing. it doesn't show up in the code.

I'd like to add a custom CSS file so that I can better study this sticky footer situation against the latest Zen realease. and then perhaps create a patch for others ;)

so any help is greatly appreciated.

cheers,
Luciano

KrisBulman’s picture

any luck with this Luciano?

by doesn't work, i mean the footer simply does not stick! :P

I've attempted to apply the footer css directly to the themes css files as well as move the page.tpl.php code around according to the structure here:

http://www.cssstickyfooter.com/using-sticky-footer-code.html

and the footer still does not stick. Has anyone successfully created a subtheme using these sticky footers? link?

luco’s picture

KrisBulman, I've already released a few projects with this solution. my portfolio for example: www.luco.ws. I even succeeded in putting the footer inside rounded corners DIVs ;D if you navigate to www.luco.ws/user you'll see it sticks.

I've manually tuned the current Zen version to suit my needs, but sure enough I need to place this code for everyone - or else it's pointless.

if you want I can share with you the current Zen version I have with the sticky footer.

KrisBulman’s picture

I would most definitely appreciate it if you provided some insight into your solution!

luco’s picture

oh, ok! here you go: http://www.cssstickyfooter.com

it's all from this website. I just adapted so that it'd work with Zen.

KrisBulman’s picture

uh yeah, i guessed that and i tried (and failed) doing the same.

i was hoping for your page.tpl.php and your related css, but i guess I will have to pull it out of your site using firebug/webdev

luco’s picture

hey! no problem, man. I hadn't understood what you meant.

I'll zip my theme files and send to your email, ok?

cheers

KrisBulman’s picture

sure thing, much appreciated. If this works it could be re-contributed as a subtheme
email
kris [at] bulman.ca

KrisBulman’s picture

you can just post the tpl & css files here if it's not too much trouble, thanks!

luco’s picture

sorry man! actually I've been just CRAZY with work so I was unable to send you the stuff. it's there now.

luco’s picture

Version: 6.x-2.x-dev » 6.x-2.0
StatusFileSize
new4.78 KB

hey there,

I've successfully edited pages.css on Zen 2.0 to add sticky footer functionality. details here and here.

it's working on opera, firefox and chrome, as well as IE 7 & 8.

doesn't work on IE 6 but TBPH that browser's (gladly) not the majority anymore :)

anyway can someone test and commit?

cheers,
Luciano

luco’s picture

opps. links in #header aren't clickable unless you add z-index: 1 to it. my bad.

KrisBulman’s picture

I was able to create a vanilla subtheme using the sticky footer method, but since Zen1 is going the way of the dogs, I saw no reason to post it.

I have yet to attempt a Zen2 sticky footer.

luco’s picture

@KrisBulman, have you tried the file I attached? it seemed to work on all places but IE 6, which isn't a bad thing in my opinion. ;)

also, "the way of the dogs"? what does it mean?

cheers

luco’s picture

another slip: it seems that you have to turno off overflow:auto; in DIV #main to prevent the logo in #header from interfering with it. go figure.

luco’s picture

another thing: the DIV #main should have min-height: 0px; for IE7. I'm slowly building this on my own... hope the maintainers add it to a forthcoming release, at least ;)

bverc’s picture

subscribe

nordicmaterial’s picture

I successfully implemented a sticky footer inside my Zen2 theme (http://www.crosstalks.net/smartfooter).
Method uses CSS from the article by Stever ( http://www.cssstickyfooter.com/ ).

Here's how to proceed:

1. Modify templates/page.tpl.php .
By default, the Zen theme will put #footer inside the #page-wrapper. You need to get it OUT of there.
The footer zone should be the very last element before your tag.

This will make the last lines of page.tpl.php look like this:

    </div></div> <!-- /#main, /#main-wrapper -->

  </div></div> <!-- /#page, /#page-wrapper -->

  <?php print $page_closure; ?>

  <?php print $closure; ?>
  
  <?php if ($footer || $footer_message || $secondary_links): ?> /* this is the footer zone and it should close just before the body tag  */
      <div id="footer"><div class="section">

        <?php print theme(array('links__system_secondary_menu', 'links'), $secondary_links,
          array(
            'id' => 'secondary-menu',
            'class' => 'links clearfix',
          ),
          array(
            'text' => t('Secondary menu'),
            'level' => 'h2',
            'class' => 'element-invisible',
          ));
        ?>

        <?php if ($footer_message): ?>
          <div id="footer-message"><?php print $footer_message; ?></div>
        <?php endif; ?>

        <?php print $footer; ?>

      </div></div> <!-- /.section, /#footer -->
    <?php endif; ?>

</body>
</html>

2. Add the next lines of CSS to one of your main .css files (pages.css for example).
Footer height can be adapted of course, as long as you change it in all 3 elements.

/*sticky footer*/
html, body {height: 100%;}

#page-wrapper {min-height: 100%;}

#page {overflow:auto;
	padding-bottom: 50px;}  /* must be same height as the footer */

#footer {position: relative;
	margin-top: -50px; /* negative value of footer height */
	height: 50px;
	width: 960px;
	margin-left: auto;
	margin-right: auto;
	clear:both;} 

/*sticky footer Opera Fix*/
body:before {
	content:"";
	height:100%;
	float:left;
	width:0;
	margin-top:-32767px;/
}
luco’s picture

@nordicmaterial did you see the CSS (and fixes) I posted?

with it, you don't have to make any changes to TPLs. ;]

cheers

barraponto’s picture

Issue tags: +sticky footer
StatusFileSize
new530 bytes
new1.02 KB

I've turned the CSS fix from #18 into a patch for zen, and also created a footer.css file. You can use either fix (apply the patch, or add the footer.css file to yoursubtheme.info).

also, i have added it to my zen compass plugin, check it out at https://bitbucket.org/barraponto/compass-drupal-plugin/raw/e269a6ecd566/...

barraponto’s picture

Status: Active » Needs review
StatusFileSize
new797 bytes

oh, I hope it gets reviewed soon.

btw, I don't actually expect the patch to be applied as is to Zen. Instead, I'd put it into a separate file, and have it declared on STARTERKIT.info, although commented out. See this new patch.

barraponto’s picture

StatusFileSize
new1.6 KB

Re-rolling patch with new file.

luco’s picture

@barraponto e aí rapá, beleza?

ok now in plain English: glad you liked the CSS. hope they commit your patch. I would have patched myself, but I don't know how to yet. so thanks!

happy 2011 :]

new_B’s picture

Thank you so much! It was extremely helpful. (I was "banging my head" on this one.) #29 worked for me (in IE 7, Firefox, Opera, and Google Chrome).

new_B’s picture

I just tested with IE6, which doesn't work. The following fixes it:

In footer.css, change

#main-wrapper {
  min-height: 100%;
}

to

#main-wrapper {
  min-height: 100%;
  _height: 100%;  /* for IE6 */
}
luco’s picture

@new_B great!

but it's better to create a separate CSS file for that unfriendly browser, and call it using conditional comments. CSS hacks keep the code from passing W3C's validators, and that makes people sad :(

other than that, good job. thanks :]

barraponto’s picture

footer.css is an optional css (it is not enabled by default in the patched .info).
if we add the ie6-only code to a different file, we must add another optional ie-exclusive css file (can't add to default ie6-only file).

luco’s picture

@barraponto I understand. two separate CSS files for IE, or the optional CSS file with hacks. is there a coding standard for that?

personally I don't think any developer would be encouraged to hack CSS standards, but it's an optional file, so I'm uncertain.

plus I'm more of a redshirt :]

new_B’s picture

Thanks for the info--I really appreciate it.

I just noticed today though that the footer sticks to the bottom but there is now a big whitespace gap between the content area and the footer on shorter content pages. Have you encountered this issue as well and/or have any suggestions/ideas on how to fix it?

Thanks again.

luco’s picture

@new_B yeah, that's a byproduct of sticky footers in pages with little content. but if the footer didn't stick, you'd still have a big whitespace.

some designers resolve this by creating footers of gargantuan proportions. me, I prefer creating pages with relevant content whenever possible ;]

new_B’s picture

Thanks, luco, for the info & your help.

Just to confirm if we're both on the same "page", as I might have not described the issue properly. When I mean big whitespace gap, there is a lot of whitespace between the content and footer, pushing the footer beyond the visible area on the screen. It introduces a scroll bar requiring the user to scroll down to see the footer. It seems that the footer could be higher up and viewable without scrolling down. Is that a byproduct of the sticky footer code applied?

Thanks again--much appreciated.

n8tron’s picture

In order to remove the vertical scroll bar and white space, I had to put #header div inside of the #main div in page.tpl.php so the height worked correctly. I'm using D7 and 7.x-3.x-dev tho.

barraponto’s picture

@n8tron: i haven't tested this on d7

@new_B: IE? which browser are you using?

new_B’s picture

@n8tron: Thanks. I moved the #header div as suggested and it worked. I'm using D6 and Zen 6.x-2.0.

@barraponto: I've tested with IE6 and IE7. Thanks.

luco’s picture

Component: CSS/HTML Markup » layout.css

@new_B oh, I see. what I did was change CSS sizes around until it worked ;] AFAIK there must be a size declaration for sticky footers to work - and that changes from site to site.

new_B’s picture

@luco Sorry, I don't quite get what you mean. Can you please clarify?

Also, is the method that n8tron suggested okay too?

Thanks--much appreciated.

luco’s picture

hey @new_B :]

what I meant is that you have to specify how tall your footer is going to be. the sticky footer technique won't work unless you define, for example, that your footer's 100px tall. that way, you tell the page to have a negative 100px margin and everything fits.

also, regarding n8tron's suggestion I managed to have a sticky footer without compromising the template structure. what I did was that the negative margin and the footer height weren't exactly the same. you have to fiddle a little till it's good to go.

cheers

themusician’s picture

I wanted to let everyone know that #25 above works great on Zen 7.x-3.1 as well. A great addition to the Zen framework.

zeppelinstudios’s picture

@theMusician

Any chance you could post your page.tpl.php fix for Zen 7.x-3.1? I can't seem to make this work... Apparently the code changed a lot since nordicmaterials post :)
Thanks!

themusician’s picture

My footer code is a bit different. I needed three editable sections. I hope this helps. #25 worked great for me.

<div id="footer"><div class="section">
  <?php print render($page['footer_left']); ?>
  <?php print render($page['footer_middle']); ?>
  <?php print render($page['footer_right']); ?>
</div></div><!--/.section, /#footer -->

My CSS or #25 from above

#page-wrapper {
    min-height:100%;
}
 
#page {
    overflow:auto;
    padding-bottom:175px; /*must be the same height as the footer */
}

/*
 * Footer
 */
.region-footer {
}
#footer {
background-color:#5F6062;
position:relative;
margin-top:-175px; /*must be same height as the footer */
height:175px;
width:100%;
clear:both; 
padding-left:24%;
}
/*sticky footer Opera Fix*/
body:before {
content:"";
height:100%;
float:left;
width:0;
margin-top:-32767px;/
}
aniebel’s picture

#25 seems to work great for FF 9.01 and IE 9 but not Chrome 16.0.912.77

I find that odd. I haven't tested my particular site on any other versions of IE.

johnalbin’s picture

Status: Needs review » Closed (won't fix)

The 6.x-2.x branch is in bug-fix only mode.

ymakux’s picture