Posted by eaton on May 30, 2009 at 10:35pm
| Project: | Node Reference URL Widget |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
It'd be great to have the node/add form automatically return to the page on which the "Post a new whatever..." link was originally clicked. here's a patch that makes that possible.
| Attachment | Size |
|---|---|
| destination.patch | 3.76 KB |
Comments
#1
Tweaked version that splits the actual link-building into a helper function. This would allow other modules to display the links in a sidebar block or some custom location.
#2
As an extra bonus, this version of the patch works.
#3
I really like the functionality added by this patch.
It looks like this patch introduces redundant options. There's no need for "Create a link on referenceable content" if there are options for "Show on teaser" and "Show on full view". We should consolidate these into a single set of checkboxes such as:
Create a link on referenceable content:[ ] For teaser node view
[ ] For full node view
It also seems like the additional new function can't actually be called by other modules to display the link in some custom location, because the teaser and full node view check is still within that function, so if both teaser and full node view links are disabled, it won't return a link. I think a more appropriate function signature would probably omit the $teaser variable entirely and pass in the $node and $field:
<?php/**
* Build an individual link.
*/
function nodereference_url_field_link($node, $field) {
$link = array();
// Build link array.
return $link;
}
?>
And then a separate function for creating a straight-up link such as:
<?php/**
* Build a printable HTML link to create a new node while populating a node reference field.
*/
function nodereference_url_create_link($node, $field_name) {
$field = content_fields($node->type, $field_name);
$link = nodereference_url_field_link($node, $field);
return l($link['title'], $link);
}
?>
#4
Freshly rewritten, pretty much the way you outline. I'd like to take a moment to shake a fist at the difference between a field and a field instance, but it all sorts itself out in the end!
#5
#6
Getting there... we need to update the validation code in nodereference_url_node_link_validate() since the 'enabled' value no longer exists. This change also requires a hook_update_N() function to change the existing variables on sites, lest this module will suddenly stop working on all existing sites after updating.
#7
Rough version, but it's a stake in the ground -- update function and corrected boolean checks. Woot.
#8
Nope, that version didn't work. Doh!
The attached one should, though. In the meantime, I've learned about CCK update functions. Yay!
#9
#11
Some final tweaks - properly sets the 'destination' key, and sets the update to 6001, not 6006 -- I did a few rounds of testing on it and had to keep incrementing the update function locally.
#12
Nice! That's one clean looking update function. I'll test this out when I get a chance.
#13
Very nice feature!
#14
Patch works great. Thanx!
#15
I have applied the patch, the update went ahead without error and the functionality works as described. Thanks!
#16
I'm gonna apply this sucka, because I want & need the shiny that appears in eaton's video: http://www.lullabot.com/articles/photo-galleries-views-attach
Edit: looks to be working fine after some *basic* testing (my specific use case only) - however I do think the text in the "return path" selector is a bit flaky. It needs to be clearer what each of these cases is. Myself, I'd assumed that the "page the link was clicked on" meant the same as the "node being referenced" and in my case it wasn't altogether clear which I ought to pick. Given that trial & error with fields isn't simple, I think this requires a little attention :)
#17
Any suggestions on what wording would be clearer? "The page the link was clicked on" could be a listing view, the front page, or any other place that the referenced node appears. For example, let's say you have a view at the url "galleries", and node 1 is a gallery. On the "gallery" page you click a link to create a new image in gallery 1.
"Default" means you would stay on the newly posted node's page.
"Referenced node" means you would be taken to node/1, the gallery node.
"Page the link was clicked on" means you would be taken back to "galleries", because you were on that page when you clicked the link.
#18
this module works fine, should be in the next release! :)
"Default" could be "No redirect"?
"Page the link was clicked on" could be "Previous page"?
thanks for this code, excellent functionality
#19
+1 to the wordings in #18.
#20
I'm sympathetic to anyone on Windows who find the patching process a bit tedious - so if anyone needs the patched version of the .module and .install files, I'm including them in this attachment.
#21
A couple things I've found so far:
- nodereference_url_update_6001 should be nodereference_url_update_6100.
- The "Fallback behavior" value is lost on upgrade.
- The $teaser variable is not available in the nodereference_url_build_link() function, meaning that teaser is always evaluated to FALSE (so the full page setting actually controls the teaser setting).
I'm working on a reroll, but I'm a little sad that this has been RTBC for nearly 2 months, yet there are rather critical problems with the patch. :-(
#22
Doh, scratch "The "Fallback behavior" value is lost on upgrade," that was cause by my attempts in another patch to get autocomplete working.
#23
Alrighty, I applied this patch with the following changes:
- Renamed update to nodereference_url_update_6100(), since this is an update function with the 1.x branch (usually 600x is reserved for upgrading from Drupal 5).
- The $teaser variable is passed into nodereference_url_build_link(), so the "Create link on teaser" checkbox now works.
- I used most of Boris's suggestion from #18. The options are now "The new node (no redirect)", "The referenced node", and "Previous page".
- In the update function, the $field['widget']['node_link']['enabled'] option is unset, since this setting is no longer used.
- Clarified docs slightly and grouped all the link settings within a fieldset rather than #type = 'item'.
- The link title validation was broken by the change, it's now required again if either the teaser or full link option is enabled.
#24
Automatically closed -- issue fixed for 2 weeks with no activity.