So you want to add a block to your module in Drupal 7. First, define its internal name and human-readable title (for the Blocks UI) with hook_block_info(): Then, give it the permissions needed to view it, a title (to appear for your site visitors), and some content with hook_block_view(): If you want to give the […]
Tag: PHP
Customize the Drupal Search Form
Here’s an easy one: you want to customize the Drupal search form provided by the Search module in your Drupal 7 site. Fortunately, Drupal provides an easy way to do this, via hook_form_alter(). Put something like this in your theme’s template.php: This defines the appearance of the search block form, which you can then place […]
Drupal Module Development Tutorial
On my Drupal 7 site here, I wanted to create a method of automatically injecting my Google Ad banners on all content pages before the Disqus comments thread. You could do this manually, say by adding a text field to your basic page content_type with a default value of all the Google Ads JavaScript, but […]
Install the APC Opcode Cache
Note: This is an old article, and the APC Opcode Cache is now abandoned. Strongly consider installing Zend OPcache instead. APC is now effectively unsupported, although you can still install and use it. Furthermore, OPcache is included in the PHP core as of PHP 5.5, and OPcache is also available and fully supported for PHP […]
Ubuntu 14 Web Server With Apache and PHP
Ubuntu 14.04 LTS has been out for a while now, and it offers some nice enhancements over 12.04 in its default repos: Apache 2.4, PHP 5.5, and MySQL 5.5.3x. Starting from a bare server image, here’s how to get an Ubuntu 14 web server up and running for PHP. Install the Web Server Note: If […]
Drupal 7 File Descriptions
I needed to increase the maximum length of the Drupal 7 file description field that appears when you enable the File module and allow uploads in nodes. By default, the file description field restricts input to 128 characters. The Drupal 7 File Description Field This is set in file.field.inc in the File module in core […]