Hi there,
What is the easiest way to add a "create child" link to a view or a block?
Looking at the URL the paren't node's ID is the only variable I should take care os (I know the type of child I want to create - in my case it is always the same).
The link I need to create should be in the format:
node/add/picture?destination=node/XXX/children&edit[parent]=XXX
… where XXX is the ID of the parent node.
My question would be how to modify my children view so that I have that link in the footer?
Sure, there is a footer property of the view but unlikely to Drupal 5, it now has no PHP format allowed (only HTML). What should I put in there and how can I get it to accept the parent ID and put it in the right place?
Same question for placing that link in a block?
Comments
Comment #1
Uersu commentedWhen somebody answers this question, please, also just add the answer for Drupal 6! I personally and I am sure many others are also interested in this question.
Comment #2
isaac.niebeling commentedYou'll probably need to theme a view[1]. When you do, you'll create a link that is exactly as you stated, but you'll use the view $row->nid variable in D6 in place of XXX. Don't recall what the variable is in D5, but you can do a print_r to figure it out. The two links below should help; you'll need to get your hands dirty, but you'll have a ton of control over your whole view.
Rereading, what I just wrote would basically allow you to have a "add a child of this node" for each node listed in the view, but that doesn't look like what you want.
If you just want to have a link to add a child of the current node, you could make a new block that's PHP-based and drop it in just below the content block. It'd only have one line, the one with your link in it. That *should* work, though I've never tried it. You could also theme the node type you're working with and add something that checks a user's permissions and adds the add children link if he or she has the rights.
You could also change the input format of the view footer to php, if you're working as a user who has permission to do that.
Hope something in there is helpful for your situation.
Isaac
[1] http://views-help.doc.logrus.com/help/views/using-theme for Drupal 6, http://drupal.org/node/42597 for Drupal 5
Comment #3
markhalliwellCopy & Pasted: This issue pertains to the 6.x-1.x branch which is now legacy and is over two years old. If this issue is not applicable anymore, please consider closing it. Otherwise, please update this issue appropriately. Will be closed in two weeks if no response.
Comment #4
kirilius commented