Getting new comment alerts in node author´s email

To do this, we need to create a new action of type “send an email”, put %author on the author field and customize the subject and body of email to be sent; under site building>triggers>comment we need the “After saving a new comment” trigger – go to the drop down box in it and then select the Action made earlier. Click “Assign” and it´s done.

Do not forget to add under site information the email address for the “From:” field.

This was of help:

EDIT: %author causes the mail function to crash. It turns out that is sending an email to the author of the comment, not the author of the node. Use a hard coded email here then instead.


Remove hours:minutes from date, but not the date

Navigate to site configuration>date and time>formats>add format, and follow the formats explained at , and you can enter following examples:
* m/d/y will produce: 09/04/09
* D, M j, Y will produce: Fri, Sep 4, 2009
* D, M d, Y will produce: Fri, Sep 04, 2009
* l, F d, Y will produce: Friday, September 04, 2009
…as explained in

Getting rid of the “Welcome to your new Drupal website” on the front page

Frequently the home page of a drupal site only has blocks from views, but no content promoted to front page, therefore displays the “Welcome to your new drupal website” message. To get rid of that, a simple way without installing any module or hacking the core is to change the line for a:

… on the page.tpl.php. A page-front.tpl.php file can also be created for that.

Theming webforms, overriding template variables to append text into form´s textbox fields

I wanted to customize a webform, so that the labels were integrated into the textbox fields, and when clicked on them to input text the default text disappeared, similar to the form found at footer of the city magazine premium Drupal theme on

To override a template provided by a module, you locate the template file and copy it to your theme folder. When you want to pass additional variables to the template or edit the existing ones, you define a preprocess function for the template in your theme. The main role of the preprocessor is to setup variables to be placed within the template (.tpl.php) files.

The template I needed to theme is the webform-form.tpl.php, but that would modify all webforms in the site, and I happen to have 2, one on the footer (the one I wanted to theme) and the other on the contact path. The one at the footer has a node id of 14, therefore I renamed the webform-form.tpl.php to webform-form-14.tpl.php.

The webform-form template file says it has the available variables $form (the complete form array) and $nid(the node id of the webform). To inspect the variables we can use dsm($form); (or dpr($forms); for complex nested arrays). You can see that the #value for each of the components (fields) in the form needs to be set (it makes a textbox have a predefined text printed, by default is empty), the same with #attributes to attach a class name and onblur and onfocus behavior.

Now you can open the template.php file and add the following code:

function zen_preprocess_webform_form_14 (&$vars) {

// Set a default value for text inside the contact form fields.

$vars['form']['submitted']['name']['#value'] = t('Name');

$vars['form']['submitted']['email']['#value'] = t('Email');

$vars['form']['submitted']['query']['#value'] = t('Your query');

// Add a custom class and placeholder text to the name textbox field.

$vars['form']['submitted']['name']['#attributes'] = array('class' => 'nire izena',

'onfocus' => "if (this.value == 'Name') {this.value = '';}",

'onblur' => "if (this.value == '') {this.value = 'Name';}");

// Add a custom class and placeholder text to the email textbox

$vars['form']['submitted']['email']['#attributes'] = array('class' => 'nire emaila',

'onfocus' => "if (this.value == 'Email') {this.value = '';}",

'onblur' => "if (this.value == '') {this.value = 'Email';}");

// Add a custom class and placeholder text to the query textarea

$vars['form']['submitted']['query']['#attributes'] = array('class' => 'nire eskaera',

'onfocus' => "if (this.value == 'Your query') {this.value = '';}",

'onblur' => "if (this.value == '') {this.value = 'Your query';}");


Hidding the labels with CSS display:none did the rest.

Displaying a webform in a block

It can be done through views, by creating the webform and then creating a view that filters by node type: webform and the particular node id. The key here is not to display fields, but rather row style:node and style: unformatted. Display the view in a block and it will be seen on the blocks page. Make sure you select “Show complete form in teaser” in Webform Advanced Settings or you’ll just see “Go to form” in your block.

The following was of help:

Dealing with fake users and spam

When fake users sign up for accounts with the purpose of posting SPAM, it is a good idea to:

-block their accounts rather than deleting them, because a bot will typically try and register under same username and with same email address. Thus blocking, disallows it to happen again. Obviously if the user is blocked, a bot can’t register with the same username and/or same email address. If you delete the account, you are allowing that same bot to register again with the same exact information.

-under user mgmt>user settings, switch to “Only site administrators can create new user accounts”. Handy with websites with small amount of users handling content.

-under user mgmt>access rules a rule can be added to deny particular users/email addresses with the use of wildcards, such as ,which would deny any user on that domain.

-use captcha type modules.

Filefield errors when uploading a document

Got an HTTP error 0 occured { “status”: true, “data”: ….} when uploading a file to attach to a node using custom defined filefields. The following worked to solve it (as reported in, but now instead of handling uploads with ajax the page refreshes after uploading the document:

I wanted to know what made the difference between the two releases and stumbled upon
in that file, around line 271 there was something remarkeable going on.

The lines that provided the ahah wrapper where commented out !

/*    '#ahah' => array( // with JavaScript
'path' => 'filefield/ahah/'.   $element['#type_name'] .'/'. $element['#field_name'] .'/'. $element['#delta'],
'wrapper' => $element['#id'] .'-ahah-wrapper',
'method' => 'replace',
'effect' => 'fade',

So, what I did to work things out was :

  1. Just install the latest version of the Filefield module
  2. Open up with a texteditor
  3. and comment out the lines above.

If anyone can shed some light on to what this does and if this kills other functionalities that I’m not aware of, let me know.
But I just have to do it this way, cause nothing else would work.

Troubleshooting WYSWIG editor outputting html tags in the text

I am using CKeditor in my case, but some fields were being outputed as “<p>”´s etc. , after checking input filters and making changes to no avail I read in that the problem was caused by a CCK field, that was configured to plain text when it should have been to filtered text (in admin>content type>schools>manage fields>my_particular_field, under text processing it has to be set to “input filters”).

Custom sql querys in drupal

I wanted to create a view to a block that displays latest 2 news, courses that haven´t started yet and vacancies if existing. This is addressed with a union query that is written into a module. Followed this tutorial:

It is a good idea to debug custom sql queries with phpmyadmin. Correct formatting of the custom made php modules is crucial, as the opening php tag and the commented $Id have to be in different lines, as such:

// $Id: custom_views.module,v 20010/05/07 12:25:24 goba Exp $

…otherwise we can get “cannot modified header information – headers already sent by” error, as detailed in:

Drupal “The connection was reset”

I used phpMyAdmin to browse to my database. Locate the `variable` table, then look for the following variable names: cache, page_compression, block_cache, preprocess_css, preprocess_js and reset them:

01 #reset the cache configuration
02 UPDATE `variable` SET `value` = 's:0:"";' WHERE `name` = 'cache' LIMIT 1;
03 UPDATE `variable` SET `value` = 's:0:"";' WHERE `name` = 'page_compression' LIMIT 1;
04 UPDATE `variable` SET `value` = 's:0:"";' WHERE `name` = 'block_cache' LIMIT 1;
05 UPDATE `variable` SET `value` = 's:0:"";' WHERE `name` = 'preprocess_css' LIMIT 1;
06 UPDATE `variable` SET `value` = 's:0:"";' WHERE `name` = 'preprocess_js' LIMIT 1;
08 #empty the cache tables (main ones)
09 TRUNCATE `cache`;
10 TRUNCATE `cache_block`;
11 TRUNCATE `cache_content`;

After issuing this commands my local site started working. From: