drupal

Force Drupal User Logout

in

I had an interesting problem this morning. One of our team had been demonstrating Analytics SEO to a potential reseller, and had forgotten to log out of the site at the end of the demo. He didn't really want to leave them with access to his account (which is a rather powerful administrator-type account), but also didn't really want to phone them and ask them to log out. The reseller is in South Africa, so I can't exactly sneak in and delete their login cookie either.

The dangers of multiple Drupal database connections

Our latest venture, www.analyticsseo.com, is a pretty complex app for a Drupal site. There are two parts to the system:

  1. a back-end application, which crawls the web, analyses sites and competitors, and does all kinds of clever stuff
  2. a front-end application, which summarises this data, generates tasks, and manages workloads

Fortunately, Drupal makes it really easy to work with multiple databases. Simply add two database connection strings in the settings.php:

Easy Drupal content creation with FCKEditor and IMCE

All the Drupal sites I build use the FCKEditor module to provide a nice WYSIWYG editor for the content administrators.For most sites, this works fine. However, my current site has rather a lot of pictures to manage.

Styling file upload form buttons in Drupal

I've used a nice bit of CSS to style all the buttons throughout our web site, but it all falls down a bit on the file upload button. For reasons best known only to the various browser developers, this button only has limited styling capability, if indeed any at all.

There are a few solutions out there, but they are all pretty messy in terms of adding a lot of cruft to your site code. I was looking for something a bit more elegant, and which would fit neatly in with the architecture of my Drupal-based site.

Simple video comments

One of the things we're really eager to get going on Save A Million Shots is the idea of video conversation threads. The trouble is, commenting is a fundamentally different activity from posting.

If you're posting an article, you're putting in a reasonable amount of time and effort (probably!), which could include making a video file, saving it to your computer somewhere, and uploading it when you write your post

IE6 Hover The jQuery Way

Drupal includes the jQuery framework by default, which gives you easy access to a bunch of neat javascript eye-candy. I've been meaning to look into this properly for a while now, but I have at least figured out how to resolve a fairly common Drupal requirement - displaying submit buttons as text links.

Drupal pages sometimes come up blank!

OK - pretty weird problem today. My local dev Drupal site was acting a bit strange. Most page requests worked fine, but some (e.g. /logout) brought back a completely blank page. "View source" on the page showed that the source was completely blank too. No errors in the apache error log, and nothing in the Drupal watchdog table.

What tokens are available in Drupal?

Drupal has a very powerful module called Tokens, which makes various pieces of data available in other modules. As an example, the Pathauto module will create friendly URLs for any piece of content based on some feature of that content, using token substitution. By default, a new piece of content will be available at the URL http://www.mysite.com/node/5 (assuming you have enabled clean URLs).

Importing Data Into Drupal CCK

I've now got a bunch of structured data in a relational database, and need to get it into Drupal. I've created my content types using CCK. Fortunately, there's a great overview here which highlights some of the core Drupal tables I need to populate which aren't immediately apparent.

Everything is pretty straightforward, apart from populating deltas for repeating fields in CCK.

An example will help here.

Suppose I have a content type of person, who can have multiple phone numbers. CCK lets me add a field of type text, which is defined as a repeating field. To the end user, this looks as though you can simply enter as many phone numbers as you like for this person.

In the database, CCK creates a table called content_type_person, which holds simple fields (i.e. fields where there can only be one value - things like first name, surname). It also creates a separate table for repeating fields, so phone numbers will be stored in content_field_contact_telephone. This new table is keyed on vid and nid (i.e. the current version of the node this person belongs to), and delta. Delta is a zero-based autoincrementing field, which increments for each new value for this nid.

Again, an example will help.

I create a new person, which is internally given nid 1 and vid 1, and added to content-type-person. If I add three phone numbers, these are added to content_field_telephone with nid and vid of 1, and deltas of 0, 1 and 2. A second person with nid 2 would get deltas 0, 1 and 2 again:

nid     vid     delta     phone
1 1 0 01234 567890
1 1 1 01234 567891
1 1 2 01234 567892
2 2 0 01234 567893
2 2 1 01234 567894
2 2 2 01234 567895

I've got hundreds of people, and several phone numbers for each. I can create the content node OK and get the right nid and vid, but how do I then insert all these into the database, and get nice zero-based incrementing delta values?

Drupal Tutorials

I'm starting to get the hang of Drupal now, largely thanks to Robert Safuto's video tutorials (especially the one about CCK and Views) - nice one Robert!

Syndicate content