Despite the absence of those who had gone to DrupalCon Copenhagen, the August Denver Drupal meet-up had a good turnout and was a great success. A lot of questions were answered and three short presentations were given about theming regions, drush and data migration.
Theming Regions
Joel gave the first presentation in response to a question about a particular theme. Often when you purchase or download a drupal theme, the theme may not exactly fit your needs. In this particular case, the theme only included a left region and a content region, which made it difficult to modify the navigation at the top of the page. Joel quickly demonstrated how to modify the theme:
- Go into your theme folder and open the .info file.
- In the file you'll see some region declarations that look like:
region[variable] = "Admin Text"
In this example, "variable" is what you'll use later to insert the region into your theme template. "Admin Text" is what appears in the Drupal block administration interface.
Add your new region and give it an appropriate variable and admin text, then save your info file.
3. Open the page.tpl.php file. To add your new region, simply add a php print statement for the corresponding variable.
For example, if you created:
region[my_header] = "My Header Region"
Then in your page.tpl.php file, you would add:
<?php print $my_header ?>
4. Clear your cache by going to http://yoursite/?q=admin/themes.
Drupal uses caching to improve performance and a quick visit to your themes administration page will force it to reload the theme. This will ensure that you're seeing the changes you just made.
5. Go to http://yoursite/?q=admin/build/block and add blocks to your new region!
Drush
Greg gave a presentation about Drush, a powerful command line interface to Drupal. A few of the drush commands that were covered include:
- si allows you to install and setup a Drupal site with a single command
- dl downloads a module, unzips it, puts it in the correct file location and can even add it to your SVN or CVS repository
- en enables modules on your Drupal site.
- up downloads module updates, backs up your old module code, installs the updated module and runs the Drupal update.php script.
With four commands, you can install and manage a Drupal website! Other commands that were covered include upwd (reset a user password) and sql-dump (create a mysql dump database backup), but that's only scratching the surface of Drush. To learn more about Drush, see the Drush website
Data Migration
Jason presented on data migration using the Table Wizard and Migrate modules. We've already blogged about migration, but here are a few tips that weren't covered in that post:
- Drupal can connect to multiple databases, so you do not need to import data into your Drupal Database. To do this, you'll need to modify your settings.php file.
The typical Drupal settings.php file declares the database as:
$db_url = 'mysql://user:password@localhost/database';
To connect to multiple databases, set $db_url as an associative array:
$db_url = array(<br /> 'default' => 'mysql://user:password@localhost/database',<br /> another_db' => 'mysql://user:password@localhost/database2',<br /> );
- Drupal has problems with multiple tables named "users." If you're trying to import data from a table named "users," you should prefix the table to keep it distinct from the Drupal users table.
- Migrate will overwrite users that have the same user ID as your imported data. This means that if your imported set of users contains a user ID #1, your Drupal administrator account will be overwritten with the imported user's data (username, password, etc). Be careful that you don't clobber your administrator account, but if you do, remember that you can always use Drush to reset the password (upwd)!
Information about upcoming meet-ups can be found at the DBUG groups page. And as always, we hope to see you at the next Denver Drupal Meetup!