Skip to main content

Drupal 7 notes - Apache config

/etc/apache2/apache2.conf - find the directory bits and make sure the /var/www one looks like:

<Directory /var/www/> 
  Options Indexes FollowSymLinks 
  AllowOverride All 
  Require all granted 

sudo a2enmod rewrite


sudo a2enmod headers


Make sure all the site configuration files in /etc/apache2/sites-available have .conf on the end (especially if upgrading from previous Apache and it doesn't seem to be backwards compatible despite what the Linode library says).

Don't forget to sudo a2ensite all-the-sites.conf


Drupal 7 notes - making javascript work in a modal

Or more accurately in my case, making a jquery gallery work inside a modal.  I am really bad at javascript so I have no idea if my hackjob is a good way to do anything but it did what I wanted.

What we needed in a recent project was for a gallery view with a thumbnail slider to launch from a gallery index comprising of thumbnails made up fo the first image in a multiupload image field.  We used Gallery Formatter (the only one that would show up in the Colorbox Node at all).

Showing up was one thing, but the jquery magic wasn't present in the modal.  I got it to work by dropping the following into a file called script.js which lives in a /js folder in my theme.


Drupal 7 notes - getting a Views block with a pager to remember what page it's on

While building this gallery for this client, I ran into an issue where if you clicked on the next page in the navigation block and selected a project on the second page, when the new project loaded the block would reload back on page 1.  The Designer and I thought that pagers really needed to remember what page they were on but as of four years ago it was a feature Views and the core pager didn't support, so at the bottom of an issue someone else opened up four years ago asking for this to happen some kind soul provided this code:


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


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.


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>


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



Thoughts on DiSo

I've had several.

Simultaneously, I've had several thoughts on which way this post was going to go.  Originally I was going to go along the vein of a blog post from Zauber Paracelsus (which outlines the "nymwars" debacle to the date of that post, people embarking on "Project DeGooglefy" and alternatives to Google services).

Then I was going to do something or other about G+ and Facebook and problems with centralised social networks.

Somewhere in there I wanted to write about the DiSo project (which appears to have died), and projects such as Diaspora and Friendika, and how I'm wanting to attempt to help with everything, and where I'm going to expend most of my efforts.

Then I started wondering what all those people that aren't me want.  Build it and they will come maybe, but "they" still need to have a use for it and be able to use it.