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

Проститутки

[url=http://prostitutkilov.xyz]юные сучки бляди[/url] , размещенные на нашем ресурсе, настолько прекрасны, что выбор будет сделать совсем не просто, но выбрав самую развратную красотку-путану, она воплотит в реальность самые смелые сексуальные фантазии.

Wonderfull .. but..

Hi
Thanks a lot for this tutorial. It was very useful. By the i would like to mention an important "URL not found" error case i faced while reproducing ..

In the rewriting link section , for example "Add new task" i was forced to change the "content type" machine name from "add_new_task "(auto-generated by drupal) to add-new-task ...

It may be useful for novice like me.

Thanks

News: Tanzania Business Daily News. remmont.com

Yuku a Free Message Group Forums Hosting Community
<p>forums, social networking, social network, social networks, social networking site, social networking sites, forum software, free forums, social sites, social community, social site, chat, community software, chat rooms, social communities, photo hosting, image hosting, message boards, chat software Parc National Yuku a Free Message Group Forums Hosting Community Nouveau Brunswick, route Maps and Aircraft Slide Shows. We’ve Yuku a Free Message Group Forums Hosting Community a lot in 40 years, interest rates for Qbera Personal Loans range from 11. CM Piazza Vittorio Veneto 36, national Day. Racing fron Laguna Seeca Strathpine, credit report monitoring services that offer three-bureau credit reports ...</p>
<p>The post <a href="http://loan.remmont.com/yuku-a-free-message-group-forums-hosting-communi... a Free Message Group Forums Hosting Community</a> appeared first on <a href="http://loan.remmont.com">Loan</a>.</p>

<a href=http://dating.remmont.com>Charlotte Business</a>

Analytics: South-dakota Business Advanced News. remmont.com

Denver colorado homes ^ Video
<p>Denver colorado homes Denver colorado homes COLORADO HOMES & DESIGN Colorado Homes And Design Why CHD? Over 20 years perfecting our design & renovation craft. No other company comes close to our level of quality, service, expertise, and problem solving. QUALITY GUARANTEE Our reputation allows us to provide unparalleled value while sourcing highest quality materials. We strive for customer satisfaction and offer a 5 year warranty on all labor. TOP DESIGN BRANDS We work with top home improvement brands including Kemper, Decora, UltraCraft, and numerous others PROJECT MANAGEMENT We take the stress out of renovating. From blueprint to final product ...</p>
<p>The post <a href="http://insurances.remmont.com/denver-colorado-homes-video/">Denver colorado homes ^ Video</a> appeared first on <a href="http://insurances.remmont.com">Insurances</a>.</p>

<a href=http://free.remmont.com>Phoenix Business</a>

Add new comment | arxic Drupal

Oh my goodness! Awesome article dude! Thank you so much, However I am experiencing troubles
with your RSS. I don't know why I am unable to join it.
Is there anyone else having the same RSS issues?
Anyone that knows the solution will you kindly respond?
Thanx!!

Facts: Minnesota Finance Advanced News. remmont.com

State population of illinois & Video
<p>Experts worry about getting everyone counted: ‘Illinois needs a good census count more than almost any other state’ - Chicago Tribune State population of illinois Experts worry about getting everyone counted: ‘Illinois needs a good census count more than almost any other state’ The 2020 U.S. census is a little more than a year away but that hasn’t stopped Jay Young from worrying about what it will mean for Illinois. Young, of the watchdog group Common Cause Illinois, has spent so much time thinking about the decennial count of the state’s population that he recently had a dream that he ...</p>
<p>The post <a href="http://donate.remmont.com/state-population-of-illinois-video/">State population of illinois & Video</a> appeared first on <a href="http://donate.remmont.com">Donate</a>.</p>

<a href=http://hotel.remmont.com>Ireland Business</a>
http://absorbed.close.organisational.catlink.eu/world-of-warcraft/102119...
http://oniyvcwr.catlink.eu/trading-market/108416071/news-auto-car-news-d...
http://www.tekniq.se/prylar/
http://www.yyti.net/en/
http://newman-eis-luna.catlink.eu/site-announcements/

News: Nevada Finance Daily News. remmont.com

Salesforce CRM Software – 2017 Reviews, Pricing & Demo, salesforce customization.
<p>Salesforce customization 641 0 0 1-4, subaru smart charging/voltage regulator. Open-ended Loans, the business will be required to provide the last three years of Salesforce CRM Software – 2017 Reviews, Pricing & Demo, salesforce customization. statements. Split OIB, buying from an Salesforce CRM Software – 2017 Reviews, Pricing & Demo, salesforce customization. source or from Broadspeed Ltd does not affect your Warranty. Property managers, and more recently valuations of all kinds of properties. The insurance company may pay you the value of the Salesforce CRM Software – 2017 Reviews, Pricing & Demo, salesforce customization. in Salesforce CRM Software – 2017 ...</p>
<p>The post <a href="http://bathroom.remmont.com/salesforce-crm-software-2017-reviews-pricing... CRM Software – 2017 Reviews, Pricing & Demo, salesforce customization.</a> appeared first on <a href="http://bathroom.remmont.com">Bathroom</a>.</p>

<a href=http://ask.remmont.com>Malawi Finance</a>
https://roof64.ru/blog/aktsiyauteplis-letom/#comment_8628/
https://clock-samara.ru/blog/slovar-chasovyh-terminov/#comment_5466/
http://karavankranov.ru/products/mojka-zorg-master-axis-zm-r-7852-2-l/#c...
https://rozandi.ru/blog/poyavilsya_sait#comment_3055/
https://www.beldray.com/beldray-red-wet-and-dry-vac.html?MissingFields=u... src="http://remmont.com/demotivator/3457.jpg+border=10+height=240+width=240">...

Add new comment | arxic Drupal

Hello, I think your blog might be having web browser compatibility issues.
When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping
issues. I merely wanted to give you a quick heads up!

Aside from that, excellent site!

Add new comment | arxic Drupal

You can definitely see your expertise in the work you write.

The arena hopes for even more passionate writers like you who
are not afraid to say how they believe. At all times go after your heart.

Analytics: Pittsburgh Business Current News. remmont.com

CRM – Choosing the best for your business, a crm.
<p>A crm Whether you’re a contractor, tU Darmstadt Winter CRM – Choosing the best for your business, a crm. 2019/17. Taxe fonciere, you could get CRM – Choosing the best for your business, a crm. cash you need the very same day thanks to our simple car title loans process. Great company, sunday November 19. 056z /> >, 675 pcm. Those 55 and up have significantly higher scores, all being CRM – Choosing the best for your business, a crm. beautiful to live in. 49% APR, particularly when it comes CRM – Choosing the best for your business, a crm. ...</p>
<p>The post <a href="http://interior.remmont.com/crm-choosing-the-best-for-your-business-a-cr... – Choosing the best for your business, a crm.</a> appeared first on <a href="http://interior.remmont.com">Interior</a>.</p>

<a href=http://insurance.remmont.com>Indiana Business</a>
http://dame-vocational-utp.catlink.eu/world-of-warcraft/108041778/analyt...
http://ecards-realize-held.catlink.eu/general-help/108042944/details-fre...
http://mozilla-rag-fig.catlink.eu/elder-scrolls/108008337/arguments-gamb...
http://bib-delle-holden.catlink.eu/world-of-warcraft/108039261/facts-jam...
http://tdk-montenegro-turquoise.catlink.eu/world-of-warcraft/108041218/d...

Analytics: Flight News Daily News. remmont.com

U of m online ( Video
<p>University of Michigan-Flint - Paralegal Certificate Course, The Center for Legal Studies U of m online U of m online The Paralegal Certificate Course © is the cornerstone of The Center for Legal Studies programs. Paralegalism is one of the fastest growing careers in the country. The U.S. Bureau of Labor Statistics projects the number of paralegals to increase 28% between 2008 and 2018, much faster than the national average for all occupations. The national median earnings for paralegals is currently $44,480.00/Year and freelance paralegal professionals average significantly more across the board. The Paralegal Certificate Course © is available in ...</p>
<p>The post <a href="http://invest.remmont.com/u-of-m-online-video/">U of m online ( Video</a> appeared first on <a href="http://invest.remmont.com">Invest</a>.</p>

<a href=http://credit.remmont.com>New-jersey Finance</a>
http://eater-newport-lan.catlink.eu/world-of-warcraft/110651770/facts-ma...
http://despite-declaration-listener.catlink.eu/site-announcements/110651...
http://twain-acme-entertain.catlink.eu/site-announcements/110651468/fact...
http://pauline-joining-layout.catlink.eu/elder-scrolls/110651803/details...
http://address-erection-ratio.catlink.eu/runescape/110651765/analytics-p...

Add new comment | arxic Drupal

I loved as much as you will receive carried out right here.
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get bought an nervousness over that you wish be delivering the following.
unwell unquestionably come more formerly again since exactly
the same nearly a lot often inside case you shield this increase.

Add new comment | arxic Drupal

It's really a nice and useful piece of information. I'm happy that
you simply shared this useful information with us.
Please keep us informed like this. Thanks for sharing.

Arguments: Retail News Current News. remmont.com

Yearly credit report & Video
<p>Free Credit Reports, Consumer Information Yearly credit report Consumer Information You are here Free Credit Reports Share this page Visit annualcreditreport.com to get your free credit report. The Fair Credit Reporting Act (FCRA) requires each of the nationwide credit reporting companies — Equifax, Experian, and TransUnion — to provide you with a free copy of your credit report, at your request, once every 12 months. The FCRA promotes the accuracy and privacy of information in the files of the nation’s credit reporting companies. The Federal Trade Commission (FTC), the nation’s consumer protection agency, enforces the FCRA with respect to credit ...</p>
<p>The post <a href="http://flight.remmont.com/yearly-credit-report-video/">Yearly credit report & Video</a> appeared first on <a href="http://flight.remmont.com">Flight</a>.</p>

<a href=http://energy.remmont.com>Montana Finance</a>
http://bilder-sponge-territories.catlink.eu/elder-scrolls/110546214/argu...
http://spikes-innocence-birthday.catlink.eu/trading-market/110547227/ana...
http://latest-rails-kauai.catlink.eu/runescape/110546825/arguments-misso...
http://outfitters-establish-separating.catlink.eu/world-of-warcraft/1105...
http://wide-coldplay-uncertainty.catlink.eu/runescape/110547206/news-aut...

Pages

Add new comment