Hello folks.
I am using Drupal to build a weekly magazine website.
I want to develop an "article" node-type, similar to 'story' but
1) with a number of custom fields (the most important one is a field to store a picture associated to each 'article')
2) with a relationship with the forum: each article will generate a topic in a specific forum room.

For a start, I am trying to understand how to implement point 1 in the 'drupal' way. I have seen a tutorial on building custom nodes, but it does not apply to drupal 5.x. Also, I have seen that drupal 5.x let the admin create custom node types, but without the possibility of adding custom fields.
Can you point to some resource or discussion?
Can you give me some starting point?
Thanks in advance,
Davide

Comments

Passero’s picture

1) you could use the Node Image module, there you can add severall images to a node
You could also use the CCK module. There you can add your own node types with there own fields.

2) Perhaps with the Actions module should it be possible but i'm not so sure about that

chestnutsmuggler’s picture

That is exactly what I was looking for. I will try to work with the CCK before typing code by myself. I will also have a look at the action module.
Thanks a million, Davide

dldege’s picture

Without doing any custom coding the solution is create content type (Drupal Core) and CCK (contributed module(s)).

So,

1. Go to ?q=admin/content/types and then ?q=admin/content/types/add
2. Choose Article for the name and article for the type then set the remaining options to your liking. Hit submit and you have created a new, custom node content type, article. This will now show up in the create content menu and you will also find options in the access control admin for controlling which roles can manipulate the new type. Furthermore, you can now customize this node type in your theme by providing a node-article.tpl.php template for theming your custom node if you want it to be different then other node types.

That's pretty much the end of what Drupal core is going to get you and its now time to pick which custom modules can get your further in your goal and/or add your own custom module code.

Adding custom fields to nodes without programming is what CCK is all about and its pretty cool. On the other hand its a lot of extra code and you can often end up with a lot of extra work at the theme level trying to get your final output of all the custom information looking the way you want it. Some times its just easier to create a custom module to add the custom data and have direct control of the output.

If you go the CCK way you need to get CCK and enable the various modules that will give you want you want. I haven't used CCK for images so I can't say exactly what you do. I have used it for custom text fields, node references, and so on. The basic operation is to go back to

?q=admin/content/types

after enabling CCK and then edit your new type, article. In the edit form you will now see options for adding and managing fields. You can then go through the process of adding new fields as needed, configuring their options, display attributes, etc.

Finally, you can now create a new article. You will see your title and body which come from Drupal core and all your custom CCK fields in the edit form. Fill it in and submit and you will see the default output of Drupal + CCK fields. Its probably not going to look the way you want it - you now have to customize your output and viewing. There is a good handbook article about theming CCK Content. The trick here is that once you start customizing it you also need to handle the node body which is not a CCK field.

http://drupal.org/node/101723
http://drupal.org/node/62462

There may also be other specialized contributed modules that can solve some or all of your needs - image, img_assist, and so on. The risk here is that you end up with so many modules and so much code to do things that it gets hard to manage and keep up to date. It also can get complicated having so much stuff coming from so many different places.

Any way you look at it you are going to have to write some custom php code if you really want to have control over how things look and feel.

dLd

chestnutsmuggler’s picture

Thanks again.
The CCK is a fanatstic tool.
I am not scared of writing code, I originally though of employing wordpress for this website, and taht would have ment writing a LOT more code. I just wanted to understand the more drupallish way of achieving my goals.
At any rate, CCK with image plugin works well so far. If it proves too 'twisted' I'll resort to developing my own node module.

As far as point 2 is concerned (one forum room per article), I'll try to write a module, and see if the actions module is necessary or not.
Thank again folks,
Davide

newdru’s picture

a way to create a module to do this (possibly outline the way you did the cck)?

I ask because i've been at drupal for about 4 months researching all the pros and cons of diy module versus cck. i agree with you that configuring and maintaining cck will probably be a nightmare for reuse, migrations and updates so i would like to create a module to do exactly what was asked here.

i've scoured many MANY pages and sites tryign to get a handle on module development and hooks. i think i could do this myself but i'm getting a little hung up on the image upload and image field part of the node form.

I don't need you to go into basic module stuff and hooks. i think i've got a handle on that. it's mostly handing adding the new img field and associated form operations and db.

i don't really think i want to make the image a node. i'd basically like to upload to a directory and then reuse the file as needed. So an association needs to be made on any given node which file[s] it uses.

this would allow the same img to be associated with multiple nodes. once the file is uploaded, it can be used by any node. but that's going to require a filemanager of some sort to list the files, switch directories and select file[s], which means a js popup/ajax or some other form refresh to handle the change of directories.

i've been scouring the plethora of img options for the last week and i'm still not sure anything out there does what i want. there are so many, it's hard to figure out which ones creat nodes, which ones don't ,etc. Or if it allows you to use files, it lacks some other feature.

thanks for any info you can provide

chestnutsmuggler’s picture

Basically, I installed the cck and the cck image plugin. Then I added a custom 'image' field to my custom 'article' node. The images are uploaded into a "/pic" directory in the /"files" directory. This is what I have done so far.
I am VERY new to drupal: I tested it 6 days ago, and now I am writing a block module to learn to use the API.
I cant' help you at this stage. Yet I I think that, if you need such a large amount of images, you should make them into a specific node type. Once you have a node you can treat it with the drupal functions, and that gives you tons of functionality...
Of course this is just a humble suggestion; as I said I am very new to Drupal.
Good luck,
Davide