Skip to main content

Drupal 7 notes: node or page template by path

Because I always seem to manage to completely forget how to do something this basic.

template.php in theme_preprocess_page(&$variables) or theme_preprocess_node(&$variables)

  $path = drupal_get_path_alias();

  if (strpos($path, 'part_of_url') !== false) {
    $variables['theme_hook_suggestion'] = 'page__whatever'; // or node__whatever if using in a node preprocess



Drupal 7 upgrade from HELL

<p>Modded to be slightly more useful as I wrote the other one while slightly delirious.</p>


Drupal notes: backup process with drush

There's probably a script for this.  Or maybe drush is the script.  Is all good, some things are done much faster with commandline :)

drush vset maintenance_mode 1 drush cc all drush arb default --destination=../[site]-[date].tar

And if there's updates to be done:

drush up -y

At the end:

drush vset maintenance_mode 0


Blog updates, or mile long sidebars

I can't even count in miles.

I was a touch concerned about adding anything else to the sidebar as it's already quite long.  Then I had a look at the sidebars some of my friends and other miscellaneous people have on their blogs and I don't feel too bad adding a couple of blocks.  Then of course there was a mental kerfuffle about folds and whether blocks should be above or below them.  I eventually decided to keep "About" up the top as it summarises the silly blog, and drop everything else in under it.

So the new blocks:


Sharing is...

...privacy concerning if you're one of those people that object to things like tracking you around the internet, and not a big deal if you're not.


Brain implosion imminent. Or what's been happening.

My head.  It's so full of stuff that I have a very mild persistant headache.  The cold isn't helping either, it makes my shoulder hurt.  I'm glad I don't live somewhere that's actually cold.

Following is a thought dump so I can work out what I'm doing and so anyone that cares can now know why techno was gone for the last month and why I've been in such a ridiculous distracted foul mood.


Drupal 7 notes: html5 placeholder text

<p>Fairly straightforward. Mostly here as a reminder for how to do <a href="">webforms</a&gt; (example has a theoretical nid of 1 and a theoretical form field called "message" and the "submitted" part stymied me for a bit).</p>

<blockquote><?php function mytheme_form_webform_client_form_1_alter(&$form, &$form_state, $form_id) {
$form['submitted']['message']['#attributes']['placeholder'] = t('Type your message here...');
} ?></blockquote>


Sprat does not share my scss enthusiasm

bek 6/04/12 10:23 PM
hee hee other cool thing with sass, i do this:

@mixin inline-block {
 display: inline-block;
 margin: 0 -2px;
 vertical-align: top;

and then when i need things inline-blocked etc (in a few places) i do:

#container {
 .stuff-what-needs-inlining {
   @include inline-block;

Darqx 6/04/12 10:24 PM
i look at that and see what looks to be php mixed with css and want to run away screaming


css notes: fixed middle fluid outer column

Also known as: I'm a blithering idiot.

I spent way too long overthinking this problem and only finding solutions with floats (I have very specific cases where I'll use floats for layout, also I could have missed anything that didn't use floats for layout as I was stupidly staying up way too late when working on this). The way to do it is actually embarrassingly easy. I'll be using it for the header and footer (after I've installed Sassy, prepro and phpsass).

header showing divs for 3 col layout for a fixed width middle and fluid outer columns

The above image is a screenshot of the header image on my local as seen in Opera (because it was the only one that showed the outlines regardless of the z-index).  The middle columns are 950px wide (specifically set in the footer due to it being a background image, not set in the header as the image isn't backgrounded and the div sizes itself to it).

What I specifically needed was for the continuation images to start from the edges of the middle div (the left continuation image of the header and both footer continuations are uneven) and stretch to the edges of the container (which is the same width as the browser window, however wide that may be).


theAbysmal Calendar Drupal module

I think it's done now.

  • fixed an issue where the years weren't being calculated properly (?!)
  • I may be slightly out of sync with the official documentation, at least according to the tests I've done on my local so far.  This year should match up, and so will key dates (New Year Day and Leap Day).  I've shifted leap years to fall on multiples of 4 so calculating would be a simple case of if mod 4 is 0, it's a leap year, if mod 128 is 0, it's not a leap year, so some of my years will be a day or two out

name = theAbysmal Calendar description = Converts Gregorian date to theAbysmal date core = 7.x package = Date/Time