Skip to main content

Drupal

Drupal: How to create a View that shows results only from the current node

Let's say you want to create a Views block that shows on a bunch of different pages/nodes that have multiple (imagefield) images per page, and you want the block to dynamically display ONLY the images from the particular node you're on--and not display images from other nodes.

This is how you would do it:

1. Create your view as you normally would.
2. Add "Node: Nid" under "Arguments".
3. Select "Provide Default Argument" under "Action to take if argument is not present:"
4. Select "Node ID from URL" under "Default argument type:"
5. Leave everything else as is...
6. Hit "Update" and then "Save"... and you're done.

How to place drupal blocks anywhere in content.

If you're looking to place a block anywhere inside your content, simply do the following:

go to /admin/build/block

select the block you want to insert into your content to get the proper block references...

e.g. I created a custom views block called "latest_news" which, if you click it's url looks like:
/admin/build/block/configure/views/latest_news-block

so basically, you'll use "views" at the beginning of the function reference and "latest_news-block" at the end:

<?php
$block
= module_invoke('views', 'block', 'view', 'latest_news-block');
print
$block['content'];
?>

Or if you want to do just a regular block... just click on it to get the url...

How to add custom javascript into the drupal webform module <form> <submit>

Recently, one of our clients asked to have custom tracking code implemented into their form submissions.

Since the client's site is built on Drupal, all forms are dynamically generated using the Webform module.

Their marketing company instructed us to add an 'onclick' code to :

<input type="submit" class="form-submit" value="Receive Coupons" id="edit-submit" name="op" onclick=tracking("track_submit_quote") />

However, since the Webform module creates all forms dynamically, there was no convenient way of hard coding the code into the form... i.e. there was no way for this to be done via webform admin.

How to install PECL uploadprogress

On Linux server:

  1. # cd /usr/local/src/
  2. get the latest version http://pecl.php.net/package/uploadprogress
  3. # tar xvfz uploadprogress-VERSION.tgz
  4. # cd uploadprogress-VERSION
  5. # export PHP_PREFIX="/usr/local"
    # $PHP_PREFIX/bin/phpize          
    # ./configure
    # make
    # make install
  6. open your php.ini
    e.g.
    # vi /usr/local/lib/php.ini

    add the line you received followed by "uploadprogress.so":

    extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so
  7. # service httpd restart

Display the (x) most recent nodes in full from a specific category

This info is likely outdated

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.