Acquia Dev Desktop – Sharing your local site

If you’re developing a Drupal site locally, using Acquia Dev Desktop 2, and you need to allow your co-workers to see it, you’ll need to make the following change to your vhosts.conf (located in devdesktop\apache\conf\vhosts.conf)

Replace “Require local” with “Require all granted”, then stop and restart Apache/MySQL from within Dev Desktop.


Using Drupal Rules Scheduler to Unpublish a Node

I use the Rules module together with Rules Scheduler (a Rules sub-module) to automatically unpublish content at a specified time, as explained in the steps below. These steps use content type = article, which has an expiry date field which is set by the user. When cron runs, the expiry date field is checked and the content is unpublished.

Step 1: Create a Rules “Component”

Here is the Rules Component to be created (in Rules export format):


Step 2: Create a “Rule” using the Rules Component

Here is the Rule to be created, in Rules export format:


Note that the above rule refers to the Rules Component from the previous step. It’s in Rules export format, just import it in your own environment via copy-paste (after you adapted article in it to fit the machine name of your content type).

Drupal remove white-space from HTML

Add this simple function into your theme’s template.php in order to strip out unnecessary whitespace and line breaks, saving a bit of file size where possible (I saved 17kb from my homepage). If a page contains a <pre> or <textarea> tag, it is left alone, as to not affect code blocks or text typed in a form.


Exclude Drupal system CSS for logged-out users

In your template.php, you can exclude Drupal’s system CSS files, or any CSS file that wasnt added by your theme (this includes CSS added by modules) using this PHP snippet:


Drupal homepage only CSS

So you want to have a base.css file on all pages, then a homepage.css file just for the homepage, and non-homepage.css for all other pages? Here’s how:

In your themes’ .info file, include the base.css file:

In your themes’ template.php file:

Note: In the code above I have chosen to inline the homepage only CSS.


Did you find this post useful?

Tip me some bitcoin:

How to add static HTML pages in Drupal

Sometimes you just need a static HTML page, or a template-less page, in your CMS. There are many ways to do this with Drupal, like creating node specific page templates, with all of the container HTML chopped out.

However, the quickest and easiest way is to use the Static Page Module

After installation, do the following:

  • Create a new Content Type, maybe call it “Static HTML”, make sure it has a “Body” field
  • In /admin/config/content/static_page, select the new content type that you created
  • Now create some content!


Did you find this post useful?

Tip me some bitcoin:

Include node specific JS/CSS in Drupal


Did you find this post useful?

Tip me some bitcoin:

Drupal: How to apply the img-responsive class to all images in your bootstrap subtheme

UPDATE: This is now included by default and should not be used.

In your subtheme’s template.php file, add the following:


Did you find this post useful?

Tip me some bitcoin: