Recent blog posts
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
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.
- Create your view. Make sure that you select "Node" as your view type as shown below

- 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.
- 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.

- 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:

- Now your views setting page should look like this.

- 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!
| Attachment | Size |
|---|---|
| views_d5.txt | 122 bytes |
- amariotti's blog
- 8370 reads

This is a cool trick. I have
Anonymous — Fri, 09/26/2008 - 00:24This 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.
I can't see the code as well!
Anonymous — Fri, 09/26/2008 - 06:00I thought it might be a browser issue, but I checked the page in different browsers and still can't see any code fragments!
Please repost CODE!!!
Anonymous — Fri, 09/26/2008 - 08:27Please repost CODE!!!
code
Anonymous — Sat, 09/27/2008 - 12:06the code does not show up! please repost it
Excellent. Great suspense
Anonymous — Sat, 09/27/2008 - 17:31Excellent. Great suspense build-up and we're still wondering what the argument is.
Maybe put your code between
Anonymous — Sun, 09/28/2008 - 07:42Maybe 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!
can you choose full html
Anonymous — Sun, 09/28/2008 - 07:43can you choose full html filter so we can see the code
Please like others have said. Filter the code for us!
Anonymous — Mon, 09/29/2008 - 03:47Please show us the solution, it appears it didn't get posted with the rest of it. :(
Code would be great!
Anonymous — Tue, 09/30/2008 - 10:43I'm planning on having an almost identical Quick Facts like-block. If you code kindly post the code that would be great!
Thanks.
My apologies everyone. I'm a
amariotti — Tue, 09/30/2008 - 23:20My 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!
Work for Drupal 6?
Anonymous (not verified) — Fri, 02/06/2009 - 11:50Will this work for Drupal 6? I'm just looking for someone to point me in the right direction. Thanks in advance.
I'll be looking over this in
amariotti — Wed, 02/11/2009 - 12:45I'll be looking over this in the upcoming days and weeks. Check this post for anything that I find.
In D6 + Views 2, set up a
Andrew Chavez (not verified) — Fri, 03/06/2009 - 18:39In 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.
Actions to take if argument
small business grants (not verified) — Thu, 03/26/2009 - 12:54Actions 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.
Good work! Your post/article
zombo (not verified) — Fri, 03/20/2009 - 02:38Good 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!




Looks like a great trick and
gaming (not verified) — Thu, 05/21/2009 - 21:48Looks like a great trick and will be very informative when the code is there!
Hi, very nice post. I have
KattyBlackyard (not verified) — Sun, 06/14/2009 - 22:38Hi, very nice post. I have been wonder'n bout this issue,so thanks for posting
Repost the code please :)
Best Insurance Tips (not verified) — Wed, 06/24/2009 - 18:23Repost the code please :)
The code for D5 is posted
amariotti — Sun, 06/28/2009 - 21:54The code for D5 is posted above. Click on the txt link and choose save as...
Post new comment