One form to create a node and block

lindsay - June 22, 2009 - 20:34

Hi everyone,

I've been Drupaling for a while now, mostly doing community sites and things like that. I have a site I am working on that is more e-commerce. To make it easy on the eventual web admin, I would like to have a custom form and when the form is filled out and saved a node would be created from some of the data and a block created from some other of the data. So if the fields were field1, field2, field3, field4 and field5 the node would display field1, field2, field5 and the block would display field1, field3 and field4.

I've used CCK to create a new type of content, in order to get my custom form. And I have looked at Node Blocks (http://drupal.org/project/nodeblock), Node as Block (http://drupal.org/project/nodeasblock), and Node in Block (http://drupal.org/project/nodesinblock), but couldn't figure out how they might work for me, if at all.

I was hoping someone here could give me some advice. Preferably module(s) that would help me achieve my goal and some general (step by step is not necessary) direction to start.

Thank you,
~Lindsay

What is the block to do? Does

davidhernandez - June 23, 2009 - 01:33

What is the block to do? Does it just show those fields, and is only visible on that node? If so, you can just use the regular node add to create a node with all the fields, and create a block that pulls the fields from the node and shows them. You could use some php in a block to load the current node and pick the fields you want, or you could use views to pull the fields you want for the current node and return only those fields.

It links to the Node

lindsay - June 23, 2009 - 02:21

Hi David,

Thanks for your input. All the block should do is show the data from the specified fields and link to the node. The block should be movable to any available block location on the site via the block admin page, and should be able to be shown on any page of the site.

Interesting suggestion about views. I have used views to create an RSS feed before, but I admit, it was feature packed I think it's awesomeness was lost on me. I'll take another look at it.

Thank you,
~Lindsay

Yeah, views should be able to

davidhernandez - June 23, 2009 - 14:59

Yeah, views should be able to do this. You can setup an argument, and feed it the node id. Then, have it return just the fields you want. This should be movable to anywhere on the site.

Thank You

lindsay - June 23, 2009 - 15:55

David,

Thank you for the suggestion and the general direction. It's exactly what I was hoping to receive by posting my question. I'll post back here to let everyone know how it works out!

~Lindsay

Project Complete

lindsay - June 25, 2009 - 18:04

Hi,

I just wanted to follow up and say this worked wonderfully. I used CCK to make a special form (might be worth noting that each field made in CCK had to have permissions set on it, I wasted some time on that!) and display only certain fields on the preview version of the node. Then used views to display nodes of a certain taxonomy in a grid. I didn't end up going with the blocks, because grids are what I really wanted, I just didn't know it :) Thanks for the help.

~Lindsay

 
 

Drupal is a registered trademark of Dries Buytaert.