Drupal: Adding a “More from this author” block using CCK author field


Show a “More From this author” Block on nodes of specific types without using the $uid variable provided by Drupal.

Let’s assume that you don’t want to use the “Posted by: username” on your stories/nodes, but rather you have your own CCK field setup to display the name of the author.  Now this CCK field may be a reference field to author pages, or just simple text fields where the authors are typing their names.  To show a block in your sidebar that displays more articles from the same author, you will want to use Views.


This applies for Drupal 6.x only:

  • Add a new view
  • Add your fields (e.g. node->title)
  • Add your filters (e.g. node->published->yes; node->types->select your types)
  • Add your sort criteria (e.g. node->published date->desc)

Now it’s time to add the argument.  Assuming the machine-readable name of your “Author name” field is “field_byline”, you will have to add a new argument.  Select your field from the Content section and change the “Action to take if argument is not present” to “Provide default argument”.  Now in the following section, select “PHP code” and enter the following code:

if (arg(0) == ‘node’ && is_numeric(arg(1))) {
$by_line = $node->field_byline[0][‘value’];
return $by_line;

Now, go ahead and add a “Block display” to the view and place the block on any content type.  You should see the recent posts, based on the number of items you selected in your view, in a block.

Refining this view further, we should be excluding the current node so that it doesn’t show up in the list of nodes in the block.  To do this, simply add another argument, select Node: NodeID from the Node group.  Provide the default argument and select Node ID from URL as the option.  At the bottom, select “Exclude the argument”.  Save your view and visit your node again.  You will find that the node you are currently visiting will not show up in the list.

Drupal — the design errors that just won’t go away!

Recently, while designing a site in Drupal using the theme acquia prosper (awesome theme, very customizable, gives a lot of control without you needing to go deep into theme css files or sub-theming), I just happened to fumble upon a few things that just wouldn’t go away.. ah the hours wasted! Well if this can help someone, I’d be very happy.

1.  FCKEditor loves to add

tags.  Problem becomes even worse if you are making a block with only an image in it and FCKEditor just won’t let you take that

tag out.  Of course you can disable FCKeditor and enter everything manually, but I’m sure we will all agree that FCKEditor along with IMCE just makes life a lot easier when adding images to the site.  One solution is to configure the FCKEditor module so that on it adds a
tag instead of a

tag.  The other solution ties in with the second problem below

2. Even without FCKEditor, when you go and check your site on IE, you see the block is just not positioned properly! What’s going on?  You check the source and you find a

tag AGAIN around the image!  What the?  If you create a block with the intent of only including a simple image tag in the code (or anything besides text), Drupal will surround your code with paragraph tags. The tags, by default, come along with a 1em margin on both top and bottom — right, while Firefox may show your design properly, IE definitely doesn’t.  Solution?  You can always just put a small code in the CSS file.  In my case, with Acquia prosper (and Skinr module), I was able to add a custom CSS class to the block which then was defined in the local.css file:

.custom-css-name p{

So that works.  You can also try a CSS override in the following manner:  #your-block-id p { margin: 0; }

Or finally, you can always create a new block input type that doesn’t convert spaces into unwanted tags.  Basically a new input format that will have the following property unchecked:

Converts line breaks into HTML (i.e.


I hope this helps if you have also run across this problem … ah that pesky

tag that just won’t go away!

If you create a block with the intent of only including a simple image tag in the code (or anything besides text), Drupal will surround your code with paragraph tags. The tags, by default, come along with a 1em margin on both top and bottom,

Drupal Updating / Upgrading

Updating or Upgrading Drupal is not an easy task.  Compared to WordPress, where the updating is simply a mouse-click away, Drupal requires you to do certain things that can take a bit of time in extremely extensive sites.  I recently had to update my Drupal installation from 6.12 to 6.14

Now this being my first Drupal installation, and as much as I love this CMS, the updating process can be a pain if not following the instructions carefully.  The instructions can be found in “upgrade.txt” file located in your drupal zip file, also you can find tons of instructions online.  An excellent website learnbythedrop.com can help you out a lot if you are looking for tutorials on Drupal.  Here’s the video I followed to help me update Drupal.  Posting it here so that it can get more recognition on the web!  They say you can fill an ocean, one drop at a time….

Drupal 6 Installation issues

Drupal 6 requires php directive “register_globals” to be off.  This is not always the case depending on your hosting environment or even your own requirements as Drupal may not be the only thing residing on your virtual server.

There are several work arounds for the issue if you come across an error during installation asking you to turn “register_globals” off.  It may work for you or it may not work for you, but the final one will definitely do the job.  Just to be safe, try the fixes in the order below:

1.  You can always add or edit the .htaccess file in your root directory with the following line:

php_flag register_globals off

This may or may not work depending on whether the apache configuration on your host allows directives to be fed through the .htaccess file.  Find out more about .htaccess files by going to http://www.freewebmasterhelp.com/tutorials/htaccess/

2. So that didn’t work huh?  Fret not, here’s another solution.  Place a “php.ini” file in your root directory with the following line:

register_globals = 0

did that work?  Basically you are telling php to initialize with the setting for your directory.

3. Wait, we didn’t cover the fact that you may be running your own server! Well if you are lucky enough to have your own server and control over your php.ini file, simply change the register_globals variable to ‘off’  in your php.ini file.  More information can be found at the php website about how to configure your php.ini file.

4. You could also try adding the following line to your .htaccess file (it has been proven to work on 1&1 webservers):

AddType x-mapp-php5 .php

This directive simply tells the server to use php5 for .php files instead of php4 (which might be the default for several webhosts out there)

5.  Ok genius, nothing worked, now what? Yup, that was my case as well, nothing worked, seemed the host didn’t allow default settings to be changed.  Well there’s always the “ask your hosting provider” answer.  If you are so inclined to do so, send them an email and ask them how to turn the “register_globals” variable off for your particular site.  They might not be of much help, but you never know.  Or, (Yes!) there’s another method.  You can simply tell Drupal to ignore it when installing.  It requires you to change the install file located in modules/system directory called “system.install“.  Go ahead and find the line:

if (!empty($register_globals) && strtolower($register_globals) != ‘off’)

and change the “!=” to “==” .   The line should now read:

if (!empty($register_globals) && strtolower($register_globals) == ‘off’)

Curious to know what you are doing here?  Well you are simply telling the system.install file change the “not equal to” to “equal to”.   Basically, you fooled the system into treating a response which would mean that “register_globals” is “on” into treating it as “register_globals” is “off”.  You will not get any more errors when doing the install now.

Now, remember, it is unsafe to have register_globals on.  Your system is not fully secure if that directive is on.  So if you are willing to take the risk, you can implement the solutions provided in this post.