By josepvalls on
Hi,
I'm stuck and I'd appreciate some advice in the task of creating some kind of children nodes for a parent node.
I have a job classifieds site and candidates can apply to positions using a webform. I want the submissions to be stored instead and the employers (and only the employer who posted the job) to be able to see the submissions and manage certain things.
I've been reading and my best guess would be some combination of Node Hierarchy and Node Access but I don't know where to start with. Any advice would be very welcome.
Thanks!
Comments
I am working on the same
I am working on the same exact problem. Although I don't know any PHP, I'm working my through Pro Drupal Development and Dupal 6 Module Development.
You will need to use the cck node reference widget. Through the views you can limit the access to certain roles but I don't yet know how to limit it the user who posted it. I figure that there must be some way to limit the access to either people who have administrative permissions or have the uid of the creater of the node the node reference widget points to. I'll look into access control or a hidden field in the application to a job that point to the nodes uid when a job application is submitted so I can use that to sort it out with a views filter.
panels
I've been doing some more reading.
For the little time I've spent dealing with drupal I've learned that it's best to try to use what's out there with minimal tweaks than build it from scratch, because whatever you do, it won't be compatible with some other module.
As for this problem.
To my understanding, the best way would be to use panels and add a pane with the node creation form of the type "job application" in the job position node type. Through arguments I'd set a hidden node_reference field in that form or something of the like. Here is where I'm stuck.
My guessing is that then I could have a variation of the same node for the role employer that instead of the apply pane would have a pane with a view inside. But again I'd need to pass in the arguments.
I'll still have to figure out the permissions so candidates could see only their submissions and employers could see only submissions to their posts.
Good luck! Please, share your progress :)
What if you created a block
What if you created a block that shows under a condition, the creator of the job posting node is viewing that node?
Under add custom block (admin/build/block/add) there is a field called 'Page specific visibility settings'. Could we do a little PHP logic that would look like this? And, would it work?
This video is one way to get
This video is one way to get a person to view content that is connected to their user ID. http://gotdrupal.com/videos/drupal-views-arguments He uses an 'argument' in views 2 to access a person's blog listings. What if we used a 'relationship' in views 2 to associate a series of applications to a job posting to a user ID by two calls to a cck node ID reference. First views makes a list of all the applications associated to a job posting trough $nid and second those are sorted to only the person with $uid that created the particular $nid of the job posting by the method used in this video so only he or she can see them?
I think that I might be getting closer but I'm not sure. Does anybody else have any ideas?
This sounds good. I've
This sounds good.
I've already tried the block approach but I think that the solution is somewhere in panels and views with arguments. I've been playing and got exactly what you mentioned.
I just read a very interesting article about how to use drupal in the public administration. Citizens were allowed to submit queries that would attach to an issue creating an administrative workflow, which was a node to be actuated on.They customized webform in order to generate new nodes of custom content types for each submission and then used trigger to start the workflow by the administration.
I think that may also be in the way of what I want do be able to do, but they didn't publish the customized modules' source.
http://drupal.subverting.org/wiki/doku.php (in spanish).
So, I've been following this
So, I've been following this lead and looks promising. Now I'm dealing with the creation of the child nodes itself.
Here is a clue:
http://drupal.org/node/564936
Cited from the post above: "Creating and rendering parent-child relationships, in an obvious and direct way, is NOT one of Drupal's strengths."
I followed reading and came across http://drupal.org/project/prepopulate which some people use with node_reference fields but I don't want things in the URL and I want the form in the same node as the parent. There is a very similar and simplier approach with this module http://drupal.org/project/nodereference_url
I found another post here http://drupal.org/node/499316 using http://drupal.org/project/relativity which looks better, but again, there is a link involved and I think there should be something even easier with panels.
just for the record, another approach at listings using views, but i don't like it very much.
http://drupal.org/node/395538
There is also this approach without using panels
http://drupal.org/project/viewfield
Summary of my solution
I keep responding myself. I hope this documentation may help somebody someday.
I found my solution also responsing myself in the following thread:
http://drupal.org/node/564936
As a summary:
CREATION OF CHILD NODES
(requires cck, content access, node reference and panels)
-Create a CCK node reference field in the child content type.
-Set the default value as PHP and get the last argument of the URL (you may want to check if it's numeric, see my comments above)
-Use content access to prevent the edition of the field
(At this point, you can add a child by going to /node/add/child-type/[parent-nid])
-Use panels to override the parent node display, add the child's node add form as a context
-Now you can go to the parent node and use the form to add a child (even if you have other paths, the arguments will be node/[nid])
DISPLAY OF CHILD NODES
(requieres views and panels)
-Create Views to list the children, add an agrument
-Use panels to override the node display and add the view there
SECURITY AND ACCESS CONTROL
(requieres rules and ACL)
-Use permissions to define which roles can create which content types
-Create a rule on saving new content that sets permissions for the creating user to view/edit the created content
Any comments for improvements are welcome
I want to document it to prevent people from banging their head agains the wall in the future.
the necessary PHP in step 2
I'm following your recipe here, and I like it a lot. The only thing is it took me forever to figure out the second step. (The module mentioned above worked like a charm, but it didn't agree with panels.) So here is the necessary code. I'm not sure the else is proper, but it seems to work fine.
There was a link to a post
There was a link to a post with the code I used. Here you are again.