By manoochehri on
Hello Drupalers:
My site requires a content type that is basically an container, with a list of items - think of something like a playlist. Each list has a title, maybe a description, and then a random length list of "things." One list might have 1 item, another might have 30...
I was planning on writing my own custom module, but I would really like to use CCK. However, I can't quite figure out how to create this content type using CCK, or if it is even possible... any ideas?
Thanks!
Michael
Comments
Multiple nodes
One way is to have a plain text field with an HTML list
<ul>or<ol>...Another option, which might offer more flexibility down the line, is to create two new node types with CCK. To use your playlist analogy, one would be 'album' and the other 'track'. You could associate all of the 'tracks' with an 'album' node. The album node could list (using the views module) all of the tracks associated with it.
In the future you could add additional fields to the 'track' node type, such as song length, rating and so on.
Using your second suggestion..
How do you actually associate the tracks with the album? Could you be specific stating steps?
I ask because i know "what" the solution needs to be theoretically. that's not the problem. the problem is implementing it within druapl. so how do i associated one content type with another in a cohesive manner?
Each of those tracks is going to have to point to an album node in a separate table. So how do i make that happen on the track form when i create the track?
thanks for any specifics you can provide..
Node reference
Using CCK create 'node reference' field in the 'track' node. In that field you can choose the appropriate 'album' node when you create each track.
To get the list of each 'track' referencing that node, you can create a view that looks for nodes with a CCK 'node reference' field that points to the current 'album'. I'm not entirely sure of the details, but you can pass parameters through the URL to customize the view. So you don't need a separate view for each and every album. One view that received a parameters (album node id in this case) and then searches for all node that have a CCK field that references that node.
man..
I want to believe you on this :-)..
but when you say things like "i'm not sure of the details" that doesn't lead me to believe that you've actually done it in which case you're not exactly sure if it works..
not trying to be an arse, but I tried node reference back in november in 4.7 and it never worked in views... it worked as far a allowing me to select the referred to cck from a referrer cck FORM.. but when it came time for views to pull the info it didn't seem to work... it's possible it's more stable now though..
which begs a different question.. the example in this thread uses 'album' so that might not be the best example for my next question but lets use it anyway..
Lets say you have 300 albums or maybe 1000. When it comes time to use the nodereference field is it going to create a select list of 1000 items on my form? I guess what i'm getting at is i wonder if nodereference is meant for smaller subsets of referred to items.. then again, if you weren't using node reference, you'd still be running up against the same problem so i guess that's more or less a universal issue (just thinking out loud)..
thanks for the replies..
Step by step instructions
I've gone through the process and written up everything I did, step-by-step.
(Drupal 5.x)
Overview
The description turned out to be pretty long so here's an overview of what we're doing.
Detailed Instructions
$args[0] = arg(1);. See Views documentation for more options.Super..
thanks for typeing that in!!!
i'll try it and get back to you soon...
Thanks for this explanation.
Thanks for this explanation. I was able to use it for my own 'child to parent', 'parent to child', node associations and it worked perfectly.
Thank you very much!
This was exactly what I was looking for and it works. However, when I enter 'node/*' under 'Show only on listed pages' I get the following error in my 'Create Content Page' (q=node/add):
* warning: Invalid argument supplied for foreach() in C:\www\drupal51\modules\node\node.module on line 504.
* warning: implode(): Bad arguments. in C:\www\drupal51\modules\node\node.module on line 508.
* user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in C:\www\drupal51\includes\database.mysql.inc on line 172.
thanks!
great example
How do you add a node?
-gryste
The write up you included is excellent for showing the referenced nodes below the content on the node id page, but what would you suggest for someone who needs to be able to add child nodes on the same form?
For example,
In your example you have Albums and Tracks. How could you add tracks to an album from the add a new album page?
Is this possible?
Thanks for your help.
re: I found this helpful...
hi all,
am new to drupal but loving it so far :)
I'm also doing something with artists, albums and tracks but in drupal 6 so could follow this guide to a point but once it got to views it's all different.. If anyone else is using v6 too then the post below might also be useful.
Between this guide and the link below I managed to get relational lists on the go - thanks for all the authors :)
http://drupal.org/node/289738
best regards,
Bernie