Posts in the “drupal” category

Create a Drupal table list view from a Drupal module

Drupal table view FAQ: How do I create a simple Drupal table view in Drupal module? I want to create a simple "list view", the sort of list view you might see in a simple CRUD application.

I just ran into this Drupal "table list" problem while creating a Drupal module, and after a lot of digging around, I found a formula that lets me display a Drupal table view like this:

Setting the Drupal front page node

Drupal front page FAQ: How do I make a Drupal page (node) the front page of my Drupal website?

Drupal front page approaches

There are several ways to control the content of your Drupal front page, but if you just want to use a Drupal node as the front page of your site, you can set this on the Site Information admin page.

The Drupal Diaries, Day 3

As a few thousand people saw earlier this morning, Day 3 of the conversion to Drupal was filled with a little comedy. First, I ran into a MySQL "can't create/write to file" error message caused by not having the open-files-limit cranked up high enough.

The Drupal Diaries, Day 10

Wow, it's taking an awful lot of work trying to keep this site running right now. The server we're currently running on is a virtual CentOS machine with 256MB RAM, and the constant traffic from both users and robots (crawlers) causes Apache to lock up from time to time. Right now I'm tweaking all the LAMP (Linux, Apache, MySQL, and PHP) knobs I know how to tweak to keep the site more or less running most of the day.

Here's a quick review of the hacks, er, performance optimizations, I've been working on.

The Drupal Diaries, Day 12

If you're interested in the really short story, this Drupal-based website is now hosted on a new, dedicated Linux server with much more RAM than the old server. For the longer story -- and the details of Apache tweaks and a script to automatically restart Apache when it got hung up -- read on.

Surprised by the Drupal plus LAMP memory use

I ended up being really surprised, but it turns out that Drupal and the LAMP architecture (Linux, Apache, MySQL, and PHP) take much more memory than the old Java-based blog that I had running the DevDaily site previously.

Mollom CAPTCHA service review

Summary: This is a review of the Mollom CAPTCHA service, based on our experiences using Mollom with Drupal here on the devdaily.com website.

When I switched this website over to Drupal about three weeks ago, I knew I also needed to find a good Drupal CAPTCHA tool to deal with both comment spam (also known as "comment form spam") and contact spam (contact form spam). After digging around a little bit, Mollom seemed like it might be a good tool, especially since both Drupal and Mollom were both created by the same author, Dries Buytaert.

My Drupal Google Analytics installation

Drupal FAQ: How do I install Google Analytics on a Drupal website?

There are two ways to do this, and I think they're both pretty easy. In the first approach you can just add the Google Analytics code to your Drupal template files, which is basically a copy and paste operation. However, if you don't want to do that, you can also use a Drupal "Google Analytics" module, and I share the link to that module below.

Drupal user login - How to tell if a Drupal user is logged in (authenticated)

Drupal user login FAQ: How can I test to see if a Drupal user is logged in (authenticated)?

If you’re creating a theme in Drupal, working with an existing Drupal theme, or developing a Drupal module, you may need to know whether a visitor to your Drupal website is currently logged in (an authenticated user), or whether they are not logged in (an anonymous user). Here's how to test to see if a Drupal user is logged in.

The cathedral, bazaar, and Drupal development

In "Diaries of a Core Maintainer #6: A tale of two developers", Angie "WebChick" Byron describes the differences in the approach of two hypothetical developers, Sloppy Sam and Perfectionist Pat. Her article is about a year old now, but if you haven't read it yet, and you have never worked on a bazaar-style software project, I really recommend reading it to understand how bazaar-style software development works (specifically the Drupal development process).

Seven free Drupal theme websites

Drupal theme websites: I recently started looking at free Drupal themes for a new website I'm developing, so I began with the usual Google search for "free Drupal themes". The good news is that there are hundreds of free Drupal themes, and dozens of websites that try to display these Drupal themes.

The bad news is that none of these sites do a really good job of displaying Drupal themes, so in an effort to save you a little bit of time I thought I'd share what I think are the "best" free Drupal theme sites.

A PHP/MySQL script to query the Drupal comments table

PHP/MySQL FAQ: Can you share an example of a PHP script that is used to query a MySQL database and then loop over the SELECT query results?

This weekend I finally fixed a minor/known bug in my PHP/MySQL script that I use to generate the Drupal sitemap for this website. (A PHP script that queries a Drupal MySQL database.) I like to update the sitemap whenever a blog post has changed, and I had all of that working, except I wasn't accounting for changes due to user comments that are approved.

The Drupal XML Sitemap module and Google

Drupal Sitemaps FAQ:How do I create an XML sitemap for my Drupal website?

If you have a Drupal website, and want to create an XML Sitemap for Google, Yahoo, Bing, and other search engines, the Drupal XML Sitemap module is the module you need. Here's what I just did to install this Drupal module it on my OneMansAlaska.com website.

A Drupal theme table example

Summary: A Drupal "theme table" example, where I show how to generate an HTML table from a Drupal module, using the Drupal theme function (and specifically not the theme_table function).

Securing the Drupal cron.php script

I don't know how big of a deal it is yet, but as I learn more about Drupal and security, I just tightened down access to the Drupal cron.php script on this site.

One thing Drupal does is make a "cron" script available off of your root URL, and by default that script is made publicly available. I don't know exactly how this works yet (other than knowing that it fires off several Drupal cleanup tasks), but I really don't want to make that URL publicly available, so after digging around I found this nice Apache configuration solution here:

A Drupal 7 SQL DELETE example

Drupal 7 SQL FAQ: How do I perform a SQL DELETE query in Drupal 7?

The short answer is that you use the Drupal 7 db_delete function, like this:

db_delete('projects')
  ->condition('id', 10)
  ->condition('user_id', 5)
  ->execute();

This example assumes that your database fields are named 'id' and 'user_id', and the values of 10 and 5 are the values in your database table you want to delete. If you just want to delete by id, your query is simpler, like this:

A Drupal form select/options field example (dropdown box)

Drupal form FAQ: How do I create an HTML SELECT/OPTIONS field in a Drupal form?

Solution: If you'd like to create an HTML SELECT field (a dropdown box) in a Drupal form that looks something like this:

A Drupal 7 form SELECT OPTIONS field example

there are at least two ways to do so.