How to Define Database Parameters in Drupal
Drupal knows which database to connect to and what username and password to issue when
establishing the database connection by looking in the settings.php file for your site. This file typically lives at sites/example.com/settings.php or sites/default/settings.php.
The line that defines the database connection looks like this:
$db_url = 'mysql://username:password@localhost/databasename';
This above example is for connecting to a MySQL database. PostgreSQL users would prefix the
connection string with pgsql instead of mysql and the username and password used
- luckyboy's blog
- Add new comment
- Read more
- 611 reads
Images and Image Galleries In Drupal
For creating an image gallery in drupal, the image module (http://drupal.org/project/image) is a good place to start. It handles image resizing and gallery creation.
There are also some very nice solutions when using CCK for displaying images inline.
Imagecache (http://drupal.org/project/imagecache) handles on-the-fly creation of image derivatives (additional modified copies of the uploaded image, such as thumbnails), while imagefield (http://drupal.org/project/imagefield) creates image upload fields within node forms.
- luckyboy's blog
- Add new comment
- 371 reads
Where are Session Stored in Drupal
Session informations are stored in the sessions table, which associates session IDs with Drupal user IDs during the DRUPAL_BOOTSTRAP_SESSION phase of bootstrapping. In fact, the $user object, which is used extensively throughout Drupal, is first built during this phase by sess_read() in includes/sessions.inc.
Here’s the table structure in which sessions are stored:
CREATE TABLE {sessions} (
uid int unsigned NOT NULL,
sid varchar(64) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
timestamp int NOT NULL default '0',
cache int NOT NULL default '0',
- luckyboy's blog
- Add new comment
- Read more
- 342 reads
How To Enable a Block During Module Installation In Drupal
Many often, you may require a block to show up automatically when a module is installed. This is fairly straightforward, and is achieved through a query that inserts the block settings directly into the blocks table. The query goes within hook_install(), located in your module’s .install file.
Here is an example of the user module enabling the user login block when Drupal is being
installed (see modules/system/system.install):
db_query("INSERT INTO {blocks} (module, delta, theme, status) VALUES
('user', 0, '%s', 1)", variable_get('theme_default', 'garland'));
- Techdipu's blog
- Add new comment
- Read more
- 508 reads
How To Define New Block Regions in Drupal
In Drupal regions are just areas in themes where blocks need be placed. You can assign blocks to regions and organize them within the Drupal administrative interface at Administer ➤ Site building ➤ Blocks.
The default regions used in themes are left sidebar, right sidebar, header, and footer,
although you can create as many regions as you want. Once declared, they’re made available to your page template files (for example, page.tpl.php) as a variable.
- Techdipu's blog
- 2 comments
- Read more
- 1255 reads













