User login

Drupal 7

Saving message entities programmatically

Our use case, re-saving existing messages, is a bit more complex than it should be, but not bad. This code will work for new or existing messages.

Where $exports is an array of long text strings that is each the JSON dump received form exporting a message type through the UI:

Set a separate browser window page title from HTML page title (Drupal 7)

This code shows how to set the browser bar page title the Page Title module way, without that module. (This was motivated simply because we were already gathering the info for another purpose in hook_node_view_alter(); there's no reason not to use Page Title!)

Setting breadcrumbs to exactly what you want

In Drupal it is quite easy to set breadcrumbs with the function drupal_set_breadcrumb(), which takes an array of links (as you would make with the l() function). It's a bit of a blunt instrument but it works (and wins out over hook_menu_breadcrumb_alter()).

How to programmatically rename a content type (change node type machine name)

Set old_type if you want to programmatically update a node type / machine name.

(This is not about changing the type of a node, but changing what type is called on the machine-info level.)

$type->old_type is what node_type_save() checks for when updating a node type, if it's not set it will create a new node type even if orig_type is set to an existing bundle. So really all you need to do right before saving a modified content type is set the old_type to the orig_type, such as:

Social Media Profile Links as a field type for Drupal 7 content

What we're looking for is a way to automatically display links on a Drupal site to people's profiles on known social media sites in the way they expect, e.g. @mlncn for Twitter, +ben.agaric for Google Plus, and whatever the heck for Facebook. Icons a plus.

Evaluated and was not impressed at all; both the inputter's user interface and the display are sorely lacking.

Blank localhost page after installing D7 locally - check your Apache logs

Using Ubuntu 12.04 -

I created a vhost on Ubuntu 12.04 using a2ensite, then I editied the config file:

sudo vim /etc/apache2/sites-available/YOUR_SITE

After saving the file, the browser loaded a blank page. When this happens you can open your Apache error log and look for the exact path that Apache is trying to find.
( tail /var/log/apache2/error.log )

The logs revealed a typo in the path to the document root for my site.

The site resolved properly after fixing the typo and restarting Apache:
sudo service apache2 restart

Format image fields to use the title as a caption printed under the image

There's a module for that:


Found via the module creator's description of why and how... before turning it into a module by popular demand.

The client would like the alt text used also as the hover text now that the title is the caption; the module does not do this... yet.

Notes on presentation about Drupal off the Island with MongoDB, AngularJS, more

Presented by Ian Mariano

[Need to ask NorthPoint Digital for the slide showing Drupal's API role in the whole mix:

UX: ASP.NET MVC, Angular.JS, HighCharts.JS
API/Admin: PHP/Drupal

Mongo: All governments. Very flexible.

Extended MongoDB with JavaScript functions, including for forecasting data with best-fit curve projection. Also normalizing imported data, flattening data for SOLR search.

Hide the empty cart in Drupal Commerce

At least for a site based on Commerce Kickstart, simply edit the view, which you can get to from the gear on the cart itself when logged in:


Under Advanced, no results behavior, remove the text result and summary for this block display only.

Save and you're done!

Syndicate content