Source Code

Source Code

(Article) Multi-step Forms in Drupal 6 using variable functions

Article : Multi-step Forms in Drupal 6 using variable functions

Goals to develop a multi-step form method

(Tips) Drupal backup script

Tips : Drupal backup script

First it is necessary to create a backup user on the database which has (only) read access to everything. This is because its password will be embedded in the backup script which reduces security. This can be done with:

BKUSR=backup
BKPW=backuppassword
BKDIR=/var/www/dbbackup
mkdir -p $BKDIR
echo "GRANT SELECT, LOCK TABLES ON *.* TO '$BKUSR'@'localhost' IDENTIFIED BY '$BKPW'; FLUSH PRIVILEGES;" | mysql -u root -p

(Source Code) Automating Drupal module activation

Source Code : Automating Drupal module activation

When upgrading a large Drupal site between major revisions, I find myself doing the update over and over again. Since one site I maintain has 149 modules, and a few more that come packaged with other contrib that are not activated, I decided I don't want to click all those checkboxes every time I do a trial upgrade. While I could have probably come up with some way to just activate every module easily, I really wanted selective activation.

(How to) How to build a node in Drupal programmatically

How to : How to build a node in Drupal programmatically

Sometimes you want to create a page or a story, or any other node-based piece of content (but not content-type) programmatically. I've searched for explanation, and once again, when I can't find something fast, I share it here. In this case I had to have some conversations.

It's quite simple. Turns out Drupal uses php standard class as the base for its nodes.

Here's how you build a node type page.

(Code) How to programmatically insert a view into a tpl or content in Drupal 6

Code : How to programmatically insert a view into a tpl or content in Drupal 6

In Drupal 6 views has been completely rewritten from the ground up, and as such we have to adjust the little code snippets that we developers have collected over the years to compensate.

The old way ( Drupal 5 views 1 ) of inserting a view into a tpl or into a php enabled content area was as follows:

(Tips) Use MySQL to double the nodes in your Drupal database

Tips : Use MySQL to double the nodes in your Drupal database

Now as a shell script. You may have to update the MySQL user in the script. A file version of the script is attached. Download it, make it executable with chmod +x ./doublenodes, and then run it with ./doublenodes databasename

#!/bin/sh

(Tips) Quick Views theming tricks in Drupal 5

Tips : Quick Views theming tricks in Drupal 5

Here is a quick views theming trick in drupal 5. Take a look on the function

  • $node->view_name : the name of the view this node is being rendered in
  • $node->position_in_view : the position within the view for this node

function phptemplate_views_view_nodes($view, $nodes, $type, $teasers = false, $links = true) {
static $count;

(Source Code) Adding timestamps to Drupal stylesheets to ensure an up to date browser cache

Source Code : Adding timestamps to Drupal stylesheets to ensure an up to date browser cache

You need to edit /includes/common.inc and add the following text to the drupal_get_css() function.

Syndicate content