Drupal 7 Entity Reference Prepopulate module - Daily Dose of Drupal episode 98

preview_player
Показать описание
The Drupal 7 Entity Reference Prepopulate module allows you to automatically populate an Entity Reference Field from the URL. This is similar to a Drupal 6 module called Nodereference URL widget, but works with all entities.

In this episode you will learn:

- How to configure the Entity Reference Prepopulate module
- How to construct the URL to get the Entity Reference Field to fill in automatically

Links:
Рекомендации по теме
Комментарии
Автор

Very helpful. Thanks for the tutorial.

goodwinpro
Автор

Damn, this little video made my night. Thank you.

jeffcouret
Автор

Shane, thank you.  This module only seems to bring me halfway there.  In your example, you use the URL string to set the field to node 6.  And you code it as "6". But that's hard coded.  How do you set a variable (or populate the URL) to get the node # of the client content?  So that when you're on the client that is node #47, the URL reads ?

theTonyTrout
Автор

I think I have found it by my self, you have to add a page manager node template for your content type and just have to add the reference add link.

nordic
Автор

Shane, I guess this is neat but I'm still not sure why someone would resort to using it...

By the way, do you happen to know of any method used to make an entity reference field that references users use something other than the username to key from? From what I understand, a module called "RealName" exists that can do this, otherwise, it's a either a view entity display or else some custom module...

(Thought I might ask to see if you were aware of anything else.)

_floW
Автор

I really wonder what is the best way to get the "Add Client" links on every node? Have you actually done some more testing with this module and figure this out?

I could imagine you could with this kind of stuff create your own forum (like) structure, only with nodes, don't even in need of the comment module.

nordic
Автор

Alright here is how I created a link:
1. click: myView > HEADER > Add
2. select: Text Area
3. select: Text Format > PHP Code (you will have to enable PHP filter module)
4. add your PHP code (I used below):
<?php
  global $user;
  if (user_access('create company content', $user)) {
    $output = l(t('Add Company'), $GLOBALS['base_url'] . . $user->uid);
    print $output;
  }
?>

jeffguroo