I am wondering if there is a way (or would be a way) to clean up the url used to populate the reference field. I noticed that thd Node Reference URL Widget that this came from has a very clean way of utilizing the URL. Instead of appending the field name with an equals sign and then the node id to be reference, it simply uses the url tagged onto the end of the url. So instead of ending up with node/add/contet_type?field_name=9, you would end up with just node/add/content_type/9. This would also add the ability to place views block on the same page as the node/add which can grab information from the node based on the URL as well.
For instance, if you want to add a review content type, and want to add the information about the place being reviewed through views, you can grab the NID from the url in addition to populating the reference field with it.
Again, maybe this is possible, maybe it's not. I don't know module development well enough or I'd come up with a fix myself.
Comments
Comment #1
mrweiner commentedAdditionally, although this would probably be a separate feature request, it would be awesome to somehow have the ability to display information from the referenced node, on the node/add page, through this module. This would eliminate the need for views in my example above.
Comment #2
rogical commentedthis does make sense, but may effect some other functions try to get the arg().
Comment #3
kaido.toomingas commentedBut what about multiple fields? Before this issue (question) I had the same thought about this issue.. But now I think its good as it is.
Comment #4
mrweiner commentedThat's a use case that I hadn't thought about before. If people use it this way, then I guess it makes sense to keep it the way it is. However, I guess the reasoning for the feature remains the same, which is that I'd like to be able to display information about the referenced node in the content creation form. Without altering the form of the URL and using views to grab the NID, is there another way to do this? I can't really think of one.
If there isn't currently a way, then it would be really nice to have this feature added in.
Comment #5
kaido.toomingas commentedWow seems like you have some hard time in there.
So what can you do?
If you turn on entity reference module you then you dont need alter a form.
This will know You want to add some stuff if you create an url node/add/article?field_yourfieldname=Your_value .
How to create it with views without any coding http://drupal.org/node/1674214#comment-6208720 .
Without views
If you are at some node page You could use function called arg() and print out your entity_id from url.
You could use custom php block for that and use code:
Comment #6
mrweiner commentedI'm sorry, but I don't really understand your instructions. Would you mind clarifying? I do understand how to setup the reference-prepopulate URL though. Also, my page is a node, and not a view. I was just trying to use a view block because I didn't know if or how I could place this information into the creation form manually.
So, if the page I'm referencing is a node, and the url is
node/add/review?field_review_venue_reference=9, what would I do to print a field such as the "Title" of the referenced node on/above the form? If I understand, your above code only gets the entity id. I'm not entirely sure how I'd use that.Comment #7
kaido.toomingas commentedNo You can not do that with this module extends only Entityreference field. So You can not use this one for other kind of fields.
Comment #8
mrweiner commentedDo you know if there is a way to achieve what I'm trying to do though, using another module or code in conjunction with this one? Or will this have to sit as a feature request?
Comment #9
kaido.toomingas commentedSeems like this one seems to be more general http://drupal.org/project/prepopulate .
.