Drupal

Some drupal pain about "q=user"

In drupal, when you go to http://www.yoursite.com/?q=user you get redirected right away to http://www.yoursite.com/?q=user/777 (if 777 is your user id and if you are logged in). If you are not logged in, you see the login page.

My client wanted users to be redirected to http://www.yoursite.com/?q=user/me instead. How simple, right? WRONG!

Sometimes, (or often in Drupal) the simpliest thing end up being a nightmare.

I wrote a drupal module to handle this:

function foo_menu($may_cache) {
  if ($may_cache) {
    $items[] = array(
      'path' => 'user',

Drupal Indexing - node.tpl.php is for layout only

If you are working on drupal, I am sure you were asked at one point to display additionnal data on a node page. Or maybe to filter the data. For example, only show tags from some vocabularies, but not all of them. The very first reaction might be to modify node.tpl.php to call some function that will return the new data and echo the data.

Let's assume (for simplicity) that the defualt node.tpl.php looks like this by default:

<div class="node">
  <h2><?php echo $title ?></h2>
  <?php echo $author ?> wrote on <?php $node->created ?><br />
  <?php echo $content ?><br />

Why is Drupal still using CVS?

Angie wrote a nice article that explains why Drupal looks like it is still living in dark ages..

http://drupal.org/node/289117

explode() is not strpos() - [empty() is not broken]

Let's say that I worked on a recipe website.
The goal was to generate some HTML whenever we had one or more ingredients to show.
The data comes from a legacy MS-SQL server which returns a comma seperated list of ingredients.
When no ingredients are found, do not display the ingredient block and title.

I coded something like this:

  $ingredients = explode(',', $mssql_row['INGREDIENTS']);
  if (!empty($ingredients)) {
    $output .= theme('item_list', $ingredients, t('List of ingredients'));
  }

PS: I was using Drupal, that is where theme() and t() comes from.

Proposed Drupal Module : views_active_filters

This is a new module that I would like to contribute on drupal.org. Feel free to comment and download the source for review.

Before I install Drupal

Whenever I start a new drupal project, my first task is to setup a version control repository. I have used CVS for 8 years but now that I had a taste of SVN, that is all I am using. Once I setup the repositary I create the folder for the project:

svn mkdir file:///var/svn/myproject -m "Creating initial folder for my project"

Then I download the latest version of the drupal series I want to install. Since a number of critial modules are not yet ported to Drupal 6 (views, cck, panels to name a few) I stick to Drupal 5 for now.

 

Syndicate content