amariotti.com

  • about
  • blog
  • portfolio
  • resumé
  • modules
  • contact
Home › Blogs › amariotti's blog

Recent blog posts

  • Text Formatter Module
  • Cool Apache ReWrite Trick
  • New RSS Feed
  • Find My iPhone
  • Congratulations, Drupal!
  • Re-Launched on Drupal 6
  • Copying + Pasting from Word into Drupal
  • Page Not Found on Node Creation
  • 1 Year
  • Happy Birthday WWW!
more

Recent comments

  • Turning off PHP suhosin
    36 weeks 11 hours ago
  • The code for D5 is posted
    36 weeks 1 day ago
  • Repost the code please :)
    36 weeks 5 days ago
  • Hi, very nice post. I have
    38 weeks 1 day ago
  • Great post! I'll subscribe
    38 weeks 4 days ago
  • Cool! It works perfectly..
    39 weeks 6 days ago
  • I'm having the same problem.
    40 weeks 4 days ago
  • Hello again. It's working but
    40 weeks 4 days ago
  • I'm having the same issue, it
    40 weeks 5 days ago
  • Yes, when I open the page I
    40 weeks 5 days ago

Blog tags

drupal drupal 6 drupal issue liquidweb module modules that I love os x random rss Salesforce.com software theming
more tags

Displaying CCK Data only in a Block (vs. in the node content) [UPDATED]

amariotti — Tue, 04/22/2008 - 14:51

I had a challenge that I wanted to share on my blog, so here it is. For my job I'm creating a new website with a page for each Program that we offer (i.e. Welding, Medical Assisting). There is a set of quick facts that need to be associated with each program, but only be displayed in a block in the sidebar. These include information that might be most important to potential students.

My original thought was, that views would be the best way to go. I would just create a block with the fields that I wanted, and it would display based on the NID on the program page they were on. While that sounded really easy, it actually wasn't as easy as that. The biggest trick was figuring out what Views Argument to use to tell it to check the NID first, then display the information. The attached .txt file is the views argument that ended up working.

Drupal 5 Users The attached text file is the argument your paste into your view.


Drupal 6 Users
from Andrew Chavez

In D6 + Views 2, set up a fields-type view with an Nid argument. Set what you want shown in the block as your fields. In the argument, under "Actions to take if argument is not present:" choose "Provide default argument." Choose "Node ID from URL" and customize the rest of the argument as usual.

Drupal 6 Walkthrough

Since it would be a little better with screenshots I thought that I would add some screenshots in here to make life easier for the 5 people that actually read my blog.

  1. Create your view. Make sure that you select "Node" as your view type as shown below
  2. Change the basic settings on your view. Mainly just the Items to display to 1, which shouldn't matter because there should only be one nid returned.
  3. Add your fields that you wish to display in your block. For this example I added Node:Comment Count and Node:Updated Time. This could be valuable for sites that have lots of comments with nodes that get update regularly.
  4. Add an Argument to your view by clicking the + button next Arguments. Then select Node:NID from the list. When your options come up select the options shown in the screenshot below:
  5. Now your views setting page should look like this.
  6. Be sure and add a "Block" display to your view so you will have the option of selecting it from your blocks admin page and voila!

And there you have it! Any questions or comments regarding my walkthrough? Leave a comment!

AttachmentSize
views_d5.txt122 bytes
  • drupal
  • tips
  • amariotti's blog
  • 8371 reads

This is a cool trick. I have

Anonymous — Fri, 09/26/2008 - 00:24

This is a cool trick. I have been looking for a way to build a quick facts block.

By the way, I can't see the code you added to the views argument.

  • reply

I can't see the code as well!

Anonymous — Fri, 09/26/2008 - 06:00

I thought it might be a browser issue, but I checked the page in different browsers and still can't see any code fragments!

  • reply

Please repost CODE!!!

Anonymous — Fri, 09/26/2008 - 08:27

Please repost CODE!!!

  • reply

code

Anonymous — Sat, 09/27/2008 - 12:06

the code does not show up! please repost it

  • reply

Excellent. Great suspense

Anonymous — Sat, 09/27/2008 - 17:31

Excellent. Great suspense build-up and we're still wondering what the argument is.

  • reply

Maybe put your code between

Anonymous — Sun, 09/28/2008 - 07:42

Maybe put your code between and choose the full html filter so we can enjoy also.

Looks like a great trick and will be very informative when the code is there!

  • reply

can you choose full html

Anonymous — Sun, 09/28/2008 - 07:43

can you choose full html filter so we can see the code

  • reply

Please like others have said. Filter the code for us!

Anonymous — Mon, 09/29/2008 - 03:47

Please show us the solution, it appears it didn't get posted with the rest of it. :(

  • reply

Code would be great!

Anonymous — Tue, 09/30/2008 - 10:43

I'm planning on having an almost identical Quick Facts like-block. If you code kindly post the code that would be great!
Thanks.

  • reply

My apologies everyone. I'm a

amariotti — Tue, 09/30/2008 - 23:20

My apologies everyone. I'm a fool and didn't have my "view uploaded files" checked for anonymous users. All along I thought that everyone could see it. Sheesh... sorry guys!

  • reply

Work for Drupal 6?

Anonymous (not verified) — Fri, 02/06/2009 - 11:50

Will this work for Drupal 6? I'm just looking for someone to point me in the right direction. Thanks in advance.

  • reply

I'll be looking over this in

amariotti — Wed, 02/11/2009 - 12:45

I'll be looking over this in the upcoming days and weeks. Check this post for anything that I find.

  • reply

In D6 + Views 2, set up a

Andrew Chavez (not verified) — Fri, 03/06/2009 - 18:39

In D6 + Views 2, set up a fields-type view with an Nid argument. Set what you want shown in the block as your fields. In the argument, under "Actions to take if argument is not present:" choose "Provide default argument." Choose "Node ID from URL" and customize the rest of the argument as usual.

  • reply

Actions to take if argument

small business grants (not verified) — Thu, 03/26/2009 - 12:54

Actions to take if argument is not present:" choose "Provide default argument." Choose "Node ID from URL" and customize the rest of the argument as usual.

  • reply

Good work! Your post/article

zombo (not verified) — Fri, 03/20/2009 - 02:38

Good work! Your post/article is an excellent example of why I keep comming back to read your excellent quality content that is forever updated. Thank you!roulette onlinepoker sitesblackjack onlinevideo poker onlinedivx movie downloads

  • reply

Looks like a great trick and

gaming (not verified) — Thu, 05/21/2009 - 21:48

Looks like a great trick and will be very informative when the code is there!

  • reply

Hi, very nice post. I have

KattyBlackyard (not verified) — Sun, 06/14/2009 - 22:38

Hi, very nice post. I have been wonder'n bout this issue,so thanks for posting

  • reply

Repost the code please :)

Best Insurance Tips (not verified) — Wed, 06/24/2009 - 18:23

Repost the code please :)

  • reply

The code for D5 is posted

amariotti — Sun, 06/28/2009 - 21:54

The code for D5 is posted above. Click on the txt link and choose save as...

  • reply

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <b> <p> <br>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You may use <swf file="song.mp3"> to display Flash files inline

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
11 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
  • about
  • blog
  • portfolio
  • resumé
  • modules
  • contact