Drupal 7

Displaying multiple fields in a single line in drupal7 views

Suppose you have three fields (Title, field_city, field_country) to display in your view. By default they will display in three separate lines as follows:

Benjamin Franklin

To display this information in a single line, you need to edit the third field. Expand Rewrite Results, then type in the following:

[Title], [field_city], [field_country]

This will result in the following:

Benjamin Franklin, Philadelphia, USA 

Command pm-enable needs a higher bootstrap level to run

This page shows what to do when you get the following error when using drush

Command pm-enable needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.

This error is basically saying that it cannot locate drush or the correct host to execute the drush command. To solve the problem

1. Make sure you in the correct directory In command line, cd to the the directory where your drupal is installed. Then run drush en views. If you still get the error, continue to step 2.

Installing drupal using vagrant

If you are running a windows system, it can be difficult to setup several pristine drupal development environments. The simple solution is to install a virtual machine, setup your drupal such that it has no affect on the rest of your system. A better solution is to use a virtual machine workflow system that will allow you to easily create and work with several virtual machines. Vagrant is such a system and in here you will learn how to set it up.

Creating a view that sorts by count

Sometimes you have to sort something by the count of its relationship or usage. For example, you need to sort a content type by it rating or you need to sort taxonomy terms by its usage in different nodes. The key to solving these problem is to create a relationship and then aggregate it. Aggregation basically binds fields together based on a criteria such as count. Following is an example that shows how to sort taxonomy terms by their usage in different nodes. Suppose you have taxonomy "operating systems" with terms linux, mac, and windows each being used in 70, 30, 33 content types.

Setting up clean urls in drupal

Setting up clean URLs Drupal URLs have the format http://www.molecularsciences.org/?q=node/11. '?q=' does not look very nice in the URL. It also hinders using meaningful URLs. Search engines such as google and yahoo prefer clean URLs. To enable clean URLs:

Administer > Site Configuration > Clean URLs > Run the clean URL test

You should get a message like follows:

"This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL.) You have successfully demonstrated that clean URLs work on your server. You may enable/disable them as you wish."

How to turn off drupal messages

A red error message displaying on your webpage, visible to every visitor is the worst thing you can do to your site. Unfortunately, drupal displays error messages on the screen by default. There are several solutions to this problem.

1. Install disable_messages plugin

The disable messages plugin is only available for drupal 6 and drupal 7.

2. Edit page.tpl file

Remove the following piece of code from your page.tpl file

Drupal 7 - Removing authoring information from content type

To remove the authoring information you can simply edit the content type as follows:

Go to Administration >> Structure >> Content types >> edit >> Display Settings 
Uncheck "Display author and date information"
Save content type 

Another way is to edit your theme directly. If you need to remove the author and leave the date or vice versa, editing the theme would be the easiest solution. If you are not comfortable with editing the theme, then find a module that does it for you and list it in the comments below.