This website is composed of information connected through taxonomy. It is simultaneously a proof-of-concept and a means to allow Agaric to share and store information both within the collective and the world as part of our open documentation philosophy.

User login

This website is composed of information connected through taxonomy. It is simultaneously a proof-of-concept and a means to allow Agaric to share and store information both within the collective and the world as part of our open documentation philosophy.

Maintaining a Drupal project with Git: Vacating the master branch

If you've already been committing code to master, do this to start a new 7.x branch and kill off the code in the master branch so noone gets confused.

cd /path/to/repo
git checkout -b 7.x-1.x

git push origin 7.x-1.x

git checkout master
git rm -r *
echo "Real code is not kept on the master branch, to see the code: git checkout 7.x-1.x" > README.txt
git add README.txt
git commit -m "Add a README explaining that the master branch is empty."
git push origin master

Define and Use a JQuery Plugin as a Helper Function for Drupal JavaScript

Here's the basics of defining and using a JQuery plugin within the context of Drupal.

This is definitely not the best and highest use of a plugin, and may in fact be a downright abomination-- this isn't a plugin that really works outside the context of the code it is written for, and certainly not outside Drupal. But it was a clean way to abstract out 42 lines of code, so here it is, for the enjoyment of all.

The first part here is simply how to call JQuery from Drupal, the second part is the plugin.

How to fetch a file at a URL and set it as the default image in an image field

There's two separate cool things here that you might want to do. One, simply know how to save a file from a URL (there's a secret Drupal function for that in system module) and two, how to give an image field a default image when creating it programmatically (that part is outsourced to the fieldhelp module).

Set a git commit message in bash but also go to Vim for further editing

A colleague insists that messages abide by the 72 character limit advisory, and i want to change my habit to get the files-changed and, just as important, files-left-out information that git commit will give in the Vim editor.

I'm still a bit addicted to the git commit -m "Message here" workflow of entering messages right in the command line, and it's more than just habit: it is very useful to be able to look at the git add -p record.

Using Views DataSource and Feeds to pull content from one site to another... with multiple images

Disclaimer: This is a should-be-deprecated approach, both Views DataSource and Feeds can be replaced with better options, such as Services or RestWS to Rules and Rules XPath Parser. But this approach basically works now.

On the source site.

Making Views Datasource Output multiple values for an image

drush dl image_url_formatter
drush -y en image_url_formatter

Configure the View to use it for the desired image field ("Image URL" instead of "Image").

/admin/structure/views/view/yourview_xml/edit

Disabling Drupal's default notifications to the administrator when a user registers

This is not tested, but running this code (in an update hook, via Drush php-eval, however) should prevent Drupal from sending its notifications to the site e-mail address when a new, pending approval user registers:

Include a file nested within a module directory wit Drupal 7's module_load_include

The documentation for module_load_include doesn't mention it, but if a file is in a subdirectory in its module folder, or even nested several levels deeper, this module-relative path should be included with the file name in the third parameter.

Have menu local tasks (view, edit, etc. tabs) show menu item description as tooltip

Most menu items in Drupal 7 show a link tool-tip, or title, but local tasks (the tabs you are most used to seeing as the edit link tab on full node pages sadly do not follow this sensible pattern.

Until Drupal core is fixed so that menu item "description" is applied to title attribute of menu tab links", here is a fix for Drupal 7. Change this to your custom theme's name (replace 'example') and drop into your theme's template.php file:

Google Web Versus Google AJAX API Search Results

Google search results via their API vary greatly versus the results from the web interface (as an anonymous, not-logged-in user). This has been reported by others, but here is a direct test performed by me. We are fortunate in this example that the first two results are the same (albeit in reverse order). However the next results bear no resemblance to each other whatsoever.

The default Web UI returns 10 results at a time (on a page).

The default AJAX API returns 4 results at a time, and so was repeated twice advancing by four for the second result set.

Beware of transactions in Drupal 7

Drupal 7's database layer makes use of transactions in several places. Be careful when you expect to see the results of node_save() outside of the scope of the current request. If someone accesses your website data before the transaction has been committed, the results of queries executed within are not visible. Either all queries succeed or nothing happens at all in a database transactions.