Miscellaneous Drupal 7 notes

Miscellaneous notes on Drupal 7. There are Other Drupal 7 notes on this site.

Chances are that if I mention a module on this page without describing it in any way, then there’ll be mention of it in my notes on Drupal 6 modules or Drupal 7 modules. Many modules haven’t changed much between Drupal versions.

Index

Other notes

I’ve split most of my Drupal 7 notes in to several pages. See a list of them on the Drupal 7 index page.

Check my Drupal 6 notes if you don’t find what you’re looking for here, as many of them are also applicable to Drupal 7, particularly the notes on Drupal 6 modules because modules may not have changed significantly between releases. I don’t add information to this page if my D6 notes already cover it.

I also have a load useful resources in my online bookmarks, on a variety of web development and computing topics including Drupal, Drupal 6, Drupal 7 and Drupal 8.

Git

Clone

See Git documentation.

git clone -b 7.x http://git.drupal.org/project/drupal.git

This will create a directory called ‘drupal’.

Patch

See Patches.

Put the patch in the drupal root.

git apply -v [patchname.patch]
rm  [patchname.patch]

Installation profile

Standard vs minimal with no explanation of what the difference is. No useful Drupal 7 docs on their site.

Investigation on local installs reveals the following:

Minimal (sites/default)

  • Check for updates on.
  • Email notifications off.

  • No content types.
  • No configurable menus.

Modules

  • Block
  • Database logging
  • Field
  • Field SQL storage
  • Filter
  • Node
  • System
  • Text
  • Update manager
  • User

Standard (sites/site1)

  • Check for updates on.
  • Email notifications off.

  • Nice admin menu.
  • “Article” and “Basic page” content types.
  • Lightbox overlay for back end features.

Modules

  • Block
  • Color
  • Comment
  • Contextual links
  • Dashboard
  • Database logging
  • Field
  • Field SQL storage
  • Field UI
  • File
  • Filter
  • Help
  • Image
  • List
  • Menu
  • Node
  • Number
  • Options
  • Overlay
  • Path
  • RDF
  • Search
  • Shortcut
  • System
  • Taxonomy
  • Text
  • Toolbar
  • Update manager
  • User

Permissions

Administer content

You gain…

  • Update options on Content page, allowing them to perform all content ops in bulk - publish, unpublish, promote, demote, sticky, non sticky, delete, update url alias.
  • Control of revision information, authoring information, publishing options when editing a node.

Bulk update of content

To allow a role to use bulk update capabilities on content, the ‘Administer content’ permission must be granted.

Cron

Drupal 7 ships with the “poor man’s cron” module in core, so requesting cron.php via crontab is no longer necessary, though it’s better as it doesn’t hit the occasional user with the time taken to run the tasks.

  1. Set up crontab with the following:

    0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php?cron_key=[the key]

  2. The actual URL to use, with the key, can be found at /admin/reports/status.
  3. Disable the in-built cron at /admin/config/system/cron.

See Configuring cron jobs using the cron command.

Debugging

Devel module

The devel module provides a number of handy functions. One of them is dd, which will write to a log file:

dd($the_var_to_write);

It will write to a file called drupal_debug.txt in the temp directory, as indicated by file_directory_temp() (/tmp by default).

Problems (to solve!)

Hiding text filter selection from below WYSIWYG

Problem: How to hide selection, help and guidelines from below the WYSIWYG editor. The code below is for hiding them below the comment forms.

The text filter selection part of the render array is in the comment_body field of the comment form. To customise this, you register an #after_build callback function for it. The problem comes when you try to disable/hide the ‘format’ part of the comment_body, or its children, because the WYSIWYG functionality relies on reading the options of the text filter dropdown. See http://drupal.org/node/950216 and http://drupal.org/node/934976.

/**
 * Remove text format dropdown and tips from comment forms.
 */
function mymodule_form_comment_form_alter(&$form, &$form_state, &$form_id)
{
  $form['comment_body']['#after_build'][] = '_mymodule_configure_comment_form';
}

function _mymodule_configure_comment_form(&$form) {

  // You can't set the #access of 'format' to FALSE as the WYSIWYG won't load.
  //$form['und'][0]['format']['#access'] = FALSE;

  // You can't hide it as the WYSIWYG won't load.
  //$form['und'][0]['format']['#type'] = 'hidden';
  //$form['und'][0]['format']['#hidden'] = 'hidden';

  // You can unset some of its children, such as the help, guidelines and format title.
  unset($form['und'][0]['format']['help']);
  unset($form['und'][0]['format']['guidelines']);
  unset($form['und'][0]['format']['format']['#title']);

  // You can not set #access of 'format -> format' to false, nor hide it, as the WYSIWYG won't load.
  $form['und'][0]['format']['format']['#access'] = FALSE;
  $form['und'][0]['format']['format']['#type'] = 'hidden';
  $form['und'][0]['format']['format']['#theme'] = 'hidden';

  return $form;
}

Temporary workaround: Rather than altering the render array to change the markup produced, leave the markup in place and hide it via CSS

  #main fieldset.filter-wrapper {
    display: none;
  }

Potential solution: WYSIWYG later than commit a271ac7 (made 6/1/2011) adds support for a single text filter, which is hidden by Drupal - see http://drupal.org/node/950216 - so it may be possible to alter the comment_body to have the same structure as Drupal would create if only a single filter were allowed.

Last modified: 17/07/2014 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top