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

mrweiner’s picture

Additionally, 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.

rogical’s picture

this does make sense, but may effect some other functions try to get the arg().

kaido.toomingas’s picture

But 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.

mrweiner’s picture

Title: Cleaner Url » Display information about a referenced node within content creation page?

That'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.

kaido.toomingas’s picture

Wow 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:

<?php
  echo l(t('Leave a Reference!'), // change your title.
    'node/add/node_type', // this could be any entity creation url eg. admin/create/user .
    array('query' => array('field_reference' => arg(1)))
  );
?>
mrweiner’s picture

I'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.

kaido.toomingas’s picture

No You can not do that with this module extends only Entityreference field. So You can not use this one for other kind of fields.

mrweiner’s picture

Do 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?

kaido.toomingas’s picture

Seems like this one seems to be more general http://drupal.org/project/prepopulate .
.