Setting up Entity Reference content types, fields, views with Entity Reference Prepopulate add links

First, modules:

  • Views + CTools
  • Entity Views Attachments
  • Entity Reference 7.x-1.0-rc1
  • Entity reference prepopulate 7.x-1.0
  • References dialog 7.x-1.0-alpha3

Then, content types and fields:

  • Create four or more content types. For this example, I will use Client, Work, Task, and Note. Tasks and Notes can be 'attached to', e.g. entity reference, Client and Work nodes. Also, Work nodes can be attached to Clients. In my use case, I have several other content types, which can 'have' Tasks and Notes as well. The other content types in my use case also have entity references to Client and Work nodes.
  • Client is the ultimate parent content type, so you don't need any entity reference fields on it (unless you want them for some other purpose, of course).
  • On the Work content type, create an Entity Reference field using the autocomplete widget, called 'Client'. You can make it required if you want, but it does not have to be.
    • Check the "Enable Entity reference prepopulate" box, select "Disable field" for Action and "Do nothing" for Fallback behaviour. I usually set Skip access permission to "Administer site configuration".
    • If you want to enable the References Dialog widget to be able to add/edit a Client from the node add page for a Work, check the Edit and Add dialog boxes

  • In the 'Client' field settings, leave the Number of values at 1, Target type is "Node", and select "Client" for the Target bundles

  • Now, on the node add page for the Work content type, you will see the Client Entity Reference Field, with the Add Client link supplied by the References Dialog module:

  • Then, on your Task and Note content types, create (separate) Entity Reference fields called 'Attached to' (machine names: field_task_attachedto and field_note_attachedto), that can reference an unlimited number of Client, Work, and whatever other content types that you desire. You should use different fields for ease of management, but the settings are the same.
    • Check the "Enable Entity reference prepopulate" box, select "Disable field" for Action and "Do nothing" for Fallback behaviour. Set Skip access permission to "Administer site configuration".
    • You will not be able to use the References Dialog links since you are enabling the field to reference an unlimited number of different content types. With child content like "notes" and "tasks", you presumably are not going to be creating a parent, like a "client", when you are creating a "note" for the "client" - the "client" parent node will already exist.

  • In the Attached to field settings, select "Unlimited" for the Number of values, set the Target type to "Node", and select the Client, Work and any other content types to which you want to be able to attached Notes and Tasks under Target bundles.

  • Remember to create your "Attached to" Entity Reference field on both your Note and Task content types. If you recycle the field, it will have the same settings for both Notes and Tasks, so if you want to be able to attach Notes, but not Tasks, to some content types, then use two separate fields with the same settings.
  • First, create your Views to display the Notes and Tasks attached to a referencable node being viewed. I also have pages to display all of the Notes and Tasks, but I want to be able to see all of the Notes and Tasks attached to a Client or Work on the Client and Work nodes. Here, Entity Views Attachments (which is a great and useful module) comes into play. I'll use the example of Tasks again, but the process is basically the same for Notes - just change anything that was specific to Tasks to Notes when creating that View.
    • At admin/structure/views, click the "Add new view" link, name it something like "Attached Tasks" and select Show Content of type Task. Uncheck create a page, and leave create a block unchecked.
    • Use the "+Add" button near the top, to add an "Entity content" display to your newly created View
    • Under the "Entity Content Settings" pane, select "Node" for the "Entity type", and select the content types that can be referenced by the "Attached to" Entity Reference field on the Task content type (e.g., Client, Work, etc.). Leave Arguments at id. I opted to display the title of the View display by selecting "Yes" for Show title.
    • Add the fields that you want to display. Title is fine for now.
  • Then create your contextual filter, so that this Entity Views Attachment display only shows on content types referencable by the Attached to field on the Task content type, and to show only the Tasks that are attached to the node being viewed.
    • Expand the "Advanced" pane, and click the "add" button next to Contextual Filters to add your new Contextual Filter.
    • Select the "Attached to" field (machine name: field_task_attachedto), which will be listed as "Content: Attached to (field_task_attachedto)" to use as the Contextual Filter.
    • Under When the Filter in Not Available, select the "Provide default value" radio button, and then select "Content ID from URL".
    • Under When the Filter Value is Available or a Default is Provided, check the "Specify validation criteria" radio button, select "Content" for the Validator, and then select all of the content types that can be referenced by the Attached to field on Tasks (Client, Work, etc.). 
    • Leave the select list option for Action to take if filter value does not validate to "Hide view", which is the default and the desired behavior.
    • Click the apply button to save the new contextual filter that makes the magic happen!

Basic Entity Content View Display set-up:

Configuration for Contextual Filter on Content: Attached to (field_task_attachedto):

  • Now, after saving your new View, you will see Tasks listed on the nodes that are "attached to"/referenced by Tasks. Note, there is currently a bug in Entity Views Attachment that does not automatically make the Entity Content display available on content types. First go to the "Manage fields" tab for the content types, and then go to the "Manage display" tab. You should now see the Entity Content display field for the View you created, and you can position it where you would like in relation to any other fields. Here is a shot of what a Client node should look like, after you have created the Client and an attached Task:

  • Repeat the basic process of creating the EVA View to display Tasks attached to a node for the Note and Work content types. You can also display the View in a block instead of an EVA, which will allow you to display the child content type attached to a node in the sidebar or other regions of your theme.
  • Next, create the Views to be able to display "Add new [child_content_type]" links on parent nodes. Like with displaying the child content on parent nodes, you can use an EVA or a block to display the "Add new [child_content_type]" links on the parent nodes. This example will use creating the link in an EVA for the Tasks content type, but the basic process can be repeated for Notes, Works, or any other child content types - just make sure to use the correct fields and filters applicable to the work. Finally, Entity Reference Prepopulate comes into play:
    • At admin/structure/views, click the "Add new view" link, name it something like "Add new child links" and select Show Content of type All. Uncheck create a page, and leave create a block unchecked.
    • Use the "+Add" button near the top, to add an "Entity content" display to your newly created View
    • Under the "Entity Content Settings" pane, select "Node" for the "Entity type", and select the content types that can be referenced by the "Attached to" Entity Reference field on the Task content type (e.g., Client, Work, etc.). Leave Arguments at id. I opted to not display the title of the View display by leaving "No" set for Show title.
    • Add the "Content: Nid" field to your View, and remove the Title field.
    • For your filters, set the "Content: Type" filter to show only the content types that can be referenced by your "Attached to" field on the Tasks content type.
    • Change the page options so that you only display one piece of content (which will happen automatically once you set the contextual filter for this view).
  • Now, you need to set up your contextual filter on this display so that it is used only in the context of a node which can be referenced by your "Attached to" field on the Tasks content type.
    • Expand the "Advanced" pane, and click the "add" button next to Contextual Filters to add your new Contextual Filter.
    • Select "Content: Nid", listed as "Content: Nid" to use as the Contextual Filter.
    • Under When the Filter in Not Available, select the "Provide default value" radio button, and then select "Content ID from URL".
    • Under When the Filter Value is Available or a Default is Provided, check the "Specify validation criteria" radio button, select "Content" for the Validator, and then select all of the content types that can be referenced by the Attached to field on Tasks (Client, Work, etc.). 
    • Leave the select list option for Action to take if filter value does not validate to "Hide view", which is the default and the desired behavior.
    • Click the apply button to save the new contextual filter, and then save your view.

Basic Entity Content Views Display set-up:

Contextual filter configuration:

  • The final step on this View to make it usable is to rewrite your NID field so that it is output as a link on a parent node to add a new Task node with its "Attached to" field properly referencing the parent.
    • Click on the "Content: Nid" field, and uncheck the "Create a label" box
    • Expand the "Rewrite Results" section, and check the "Rewrite the output of this field" box
    • In the Text box, enter <ul><li><a href="/node/add/task?field_task_attachedto=[nid]">Add new Task</a></li></ul>
    • In the node/add/task part of the above, 'task' is the machine name of the child content type Task, and field_task_attachedto is the Entity Reference field on the child content type that can reference the parent node being viewed. Basically, with Entity Reference Prepopulate, the above link tells Drupal to go to the create new node page for a Task with the "Attached to" field pointing to the parent node being viewed. For the Notes content type and its "Attached to" field, the rewritten link will look like <ul><li><a href="/node/add/note?field_note_attachedto=[nid]">Add new Note</a></li></ul>

Now, when viewing a parent content type like a Client, you will see the Tasks attached to that client, and a link to add a new Task node from the Client. Once the Views for the Note content type are set-up, you will see the whole deal:

Drupal version: 

Comments

golden goose

I am only commenting to let you understand what a beneficial encounter my princess went through visiting the blog. She learned too many details, with the inclusion of how it is like to have a wonderful giving mindset to get certain people very easily gain knowledge of a number of very confusing subject areas. You undoubtedly surpassed readers' desires. Many thanks for delivering these warm and helpful, safe, explanatory and even cool thoughts on your topic to Gloria.

Add new comment | arxic Drupal

I like the helpful info you provide in your articles.
I will bookmark your blog and check again here frequently.
I'm quite certain I'll learn plenty of new stuff right here!

Good luck for the next!

louboutin outlet

Needed to compose you a very small note to be able to give thanks the moment again for these splendid tips you have provided on this website. It's really open-handed with people like you to give publicly all that many of us might have marketed as an e-book in making some dough for their own end, notably seeing that you might have done it if you ever considered necessary. Those basics also worked to become great way to realize that other people have the same passion just like my own to realize great deal more with reference to this problem. I am certain there are some more fun instances in the future for folks who go through your blog post.

Add new comment | arxic Drupal

I like the valuable info you provide in your articles.
I will bookmark your blog and check again here frequently.
I'm quite sure I will learn many new stuff right here!
Best of luck for the next!

Add new comment | arxic Drupal

Greetings! Quick question that's completely off topic.
Do you know how to make your site mobile friendly?
My blog looks weird when viewing from my iphone 4.
I'm trying to find a template or plugin that might be able to fix this
problem. If you have any suggestions, please share.

Thanks!

Add new comment | arxic Drupal

Hi, i think that i saw you visited my blog thus i came to “return the favor”.I'm attempting to find things to improve my website!I suppose its ok to use
some of your ideas!!

Add new comment | arxic Drupal

My partner and I stumbled over here coming from a different web address and thought I should check things out.
I like what I see so now i am following you. Look forward to looking into your web page again.

Add new comment | arxic Drupal

It's really a cool and useful piece of information. I'm happy
that you just shared this useful info with us. Please stay us informed like this.
Thanks for sharing.

vapormax

I抦 impressed, I need to say. Really hardly ever do I encounter a blog that抯 each educative and entertaining, and let me let you know, you've got hit the nail on the head. Your idea is excellent; the problem is one thing that not sufficient individuals are talking intelligently about. I'm very pleased that I stumbled throughout this in my seek for one thing referring to this.

jordan shoes

Nice post. I study one thing more challenging on totally different blogs everyday. It'll always be stimulating to learn content from different writers and follow slightly one thing from their store. I抎 prefer to use some with the content material on my blog whether you don抰 mind. Natually I抣l provide you with a link on your internet blog. Thanks for sharing.

Add new comment | arxic Drupal

I'm extremely impressed with your writing skills and also with the layout on your blog.
Is this a paid theme or did you customize it yourself?
Anyway keep up the nice quality writing, it's rare to see a great blog like this one nowadays.

off white hoodie

Youre so cool! I dont suppose Ive read something like this before. So good to search out someone with some authentic thoughts on this subject. realy thank you for beginning this up. this web site is one thing that is wanted on the web, somebody with slightly originality. helpful job for bringing one thing new to the internet!

Add new comment | arxic Drupal

It's actually a nice and helpful piece of information. I am
happy that you shared this useful info with us. Please keep
us informed like this. Thank you for sharing.

retro jordans

Nice post. I learn one thing more difficult on totally different blogs everyday. It will always be stimulating to read content material from different writers and practice a bit one thing from their store. I抎 favor to make use of some with the content material on my weblog whether you don抰 mind. Natually I抣l give you a hyperlink in your web blog. Thanks for sharing.

adidas gazelle

Spot on with this write-up, I actually think this website wants rather more consideration. I抣l probably be again to learn rather more, thanks for that info.

Add new comment | arxic Drupal

Today, while I was at work, my cousin stole my iPad and tested to see
if it can survive a 30 foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views.

I know this is completely off topic but I had to share
it with someone!

nike foamposite

I simply had to appreciate you once more. I'm not certain what I might have used in the absence of these opinions documented by you concerning my field. It seemed to be the depressing crisis in my view, however , encountering your professional strategy you treated that forced me to leap with fulfillment. I'm just happier for the support as well as hope you realize what an amazing job that you are undertaking educating other individuals all through your website. I'm certain you have never come across any of us.

golden goose

I simply wanted to post a small note to be able to appreciate you for these nice suggestions you are showing at this site. My rather long internet look up has at the end been honored with good quality facts and strategies to exchange with my friends and classmates. I 'd express that we readers actually are undoubtedly endowed to dwell in a wonderful network with so many special individuals with beneficial plans. I feel truly fortunate to have used the webpages and look forward to plenty of more fabulous moments reading here. Thank you once again for a lot of things.

Add new comment | arxic Drupal

Definitely believe that which you said. Your favorite reason seemed
to be on the internet the simplest thing to be aware of.
I say to you, I definitely get annoyed while people consider worries that
they plainly don't know about. You managed to hit the
nail upon the top as well as defined out the whole thing without having side-effects , people can take a signal.
Will likely be back to get more. Thanks

nike shox for women

I must express my thanks to you just for bailing me out of this type of condition. Because of looking through the online world and seeing tips which are not beneficial, I thought my entire life was gone. Being alive minus the strategies to the problems you've fixed all through your main posting is a critical case, as well as the ones which may have in a negative way affected my career if I had not encountered your web page. Your primary competence and kindness in maneuvering all the things was priceless. I'm not sure what I would've done if I hadn't come across such a step like this. I'm able to at this moment look forward to my future. Thanks for your time so much for the professional and results-oriented guide. I won't be reluctant to propose your blog to anyone who should get assistance on this problem.

Add new comment | arxic Drupal

With havin so much written content do you ever run into any problems
of plagorism or copyright violation? My website has a
lot of unique content I've either authored myself or outsourced but it seems a lot
of it is popping it up all over the web without
my permission. Do you know any ways to help reduce content
from being ripped off? I'd certainly appreciate it.

off white x jordan 1

Thank you a lot for giving everyone such a special possiblity to read in detail from this blog. It's always very beneficial plus full of a lot of fun for me and my office acquaintances to visit your site at the least three times per week to read the new things you have. And of course, I'm just certainly contented with all the fabulous inspiring ideas served by you. Selected two facts in this article are in fact the most impressive we've had.

Add new comment | arxic Drupal

I'm truly enjoying the design and layout of your website.
It's a very easy on the eyes which makes it much more enjoyable for
me to come here and visit more often. Did you hire out
a designer to create your theme? Exceptional work!

nike huarache

I'm also writing to make you understand of the extraordinary discovery my friend's girl found going through your blog. She realized such a lot of things, which included what it's like to possess an ideal helping mood to let the mediocre ones just master various tricky things. You undoubtedly surpassed our expected results. Many thanks for producing those precious, trustworthy, informative and cool tips about this topic to Tanya.

Add new comment | arxic Drupal

Having read this I believed it was rather enlightening.
I appreciate you spending some time and energy to put
this informative article together. I once again find myself personally spending way too much
time both reading and commenting. But so what, it was still worth it!

air max 270

Thanks so much for giving everyone remarkably pleasant opportunity to check tips from this site. It's always so enjoyable and packed with fun for me and my office mates to search your blog not less than 3 times every week to read the fresh guidance you have. Of course, we're at all times astounded considering the extraordinary principles served by you. Selected 4 ideas in this post are in reality the most efficient we have all ever had.

hermes

My husband and i felt peaceful John could round up his studies because of the ideas he was given using your blog. It's not at all simplistic just to find yourself releasing secrets and techniques which often other people may have been trying to sell. And we also do understand we have you to be grateful to because of that. These illustrations you've made, the simple web site menu, the relationships you help promote - it is all spectacular, and it's really aiding our son and us know that the theme is satisfying, which is extremely vital. Many thanks for everything!

Add new comment | arxic Drupal

Do you mind if I quote a couple of your articles as long as
I provide credit and sources back to your website? My website is in the very
same niche as yours and my users would definitely benefit from a lot of the information you provide here.
Please let me know if this alright with you.

Cheers!

jordan 6

I must point out my affection for your kindness for individuals that require guidance on this particular area of interest. Your personal commitment to getting the solution along became certainly helpful and has in most cases enabled others much like me to attain their goals. Your amazing insightful guideline means a lot a person like me and still more to my peers. Thanks a ton; from each one of us.

Add new comment | arxic Drupal

Fantastic beat ! I would like to apprentice while you
amend your web site, how can i subscribe for a blog site?
The account helped me a appropriate deal. I were a little bit familiar
of this your broadcast provided brilliant transparent concept

supreme new york

I want to show appreciation to the writer just for rescuing me from this type of trouble. After researching through the world wide web and coming across proposals which were not beneficial, I assumed my life was done. Living without the presence of approaches to the difficulties you have sorted out by means of your post is a serious case, and the kind that would have in a wrong way affected my entire career if I hadn't come across your blog. Your expertise and kindness in controlling every item was vital. I'm not sure what I would have done if I hadn't come across such a thing like this. I am able to at this time look forward to my future. Thanks for your time very much for this skilled and amazing help. I won't be reluctant to endorse your web blog to any person who ought to have guidance on this topic.

Add new comment | arxic Drupal

Oh my goodness! Impressive article dude! Thank you
so much, However I am encountering issues with your RSS. I don't know the reason why I can't join it.
Is there anybody else getting identical RSS problems?
Anybody who knows the answer will you kindly respond? Thanx!!

balenciaga trainers

Thank you a lot for providing individuals with such a brilliant possiblity to discover important secrets from here. It can be so great and full of a good time for me and my office fellow workers to visit your site at minimum three times per week to study the latest secrets you have. And definitely, I'm just actually happy with your excellent information served by you. Selected 2 ideas in this posting are completely the most impressive we have all ever had.

Add new comment | arxic Drupal

Hey this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience.

Any help would be greatly appreciated!

kyrie 3 shoes

I wish to show some thanks to you just for rescuing me from such a dilemma. Just after looking out throughout the the net and coming across methods that were not productive, I figured my life was over. Being alive devoid of the answers to the problems you've sorted out as a result of this guide is a crucial case, as well as the kind which may have negatively damaged my entire career if I had not encountered the blog. The ability and kindness in dealing with all things was vital. I am not sure what I would have done if I hadn't come upon such a stuff like this. I can at this moment look forward to my future. Thank you very much for the specialized and sensible help. I won't be reluctant to endorse your blog post to anyone who needs to have tips on this subject.

longchamp bags

My spouse and i ended up being so fulfilled when Raymond could carry out his preliminary research through your ideas he received from your very own site. It's not at all simplistic to simply happen to be giving for free guidelines which often the others may have been selling. We really see we now have the website owner to be grateful to for this. All of the illustrations you have made, the straightforward site menu, the friendships you help create - it's all fantastic, and it's making our son and our family do think that situation is brilliant, which is certainly really pressing. Thank you for everything!

Add new comment | arxic Drupal

Hello terrific blog! Does running a blog such as this
require a great deal of work? I have virtually no expertise in programming however I had
been hoping to start my own blog soon. Anyhow, if you have any ideas or tips for new blog owners
please share. I understand this is off subject nevertheless
I simply had to ask. Kudos!

Pages

Add new comment