Say I have 2 content types "Artist" and "Biography". I can use Entity Reference to link one Biography with one Artist (it's a one to one relationship).
Now when creating a new Artist, can I have a tab or a link to add an artist biography directly, instead of having to create the artist first, then the biography, and link it with an artist?
Thank you.
I don't know of one for Entity Reference but if you can swap that out in favour of the References module you can use References dialog which would be suited to your use case:
This module extends reference fields like the user and node reference fields by adding links to add, edit and search for references through a dialog. This allows for a workflow where the user can create all the references to a node at the same time as she is creating it, a process which sometimes get's a bit backwards, when a user for instance needs to create all the facts for an article.
If you're changing to a different relationship module, there's also the Inline Entity Form module which:
Provides a widget for inline management (creation, modification, removal) of referenced entities.
It embeds the add/edit form for the referenced entities into the primary entity's form so you can create multiple related entities from the same page. It also has support for nodes built right in.
Related
I am wondering if it is possible to directly edit values of a has_one relationship in SilverStripe.
For example:
Person (extension of SiteTree) has one Job (extension of DataObject) where Job has the db fields of title, salary, location etc.
Is it possible in the CMS to place a form in a new tab to edit the values of Job form the Person page? So all of the form fields from the Job DataObject are placed on the Person page and will save to the Job table when I hit save on the Person page?
I can get this to work with inline gridfield editing (thanks to the editable columns class in gridfieldextensions) but I believe this requires a has_many / many_many relationship? It also is not suitable for adding images and managing objects that have a large number of fields.
I hope that make sense. Let me know if you need more clarification.
EDIT: I found this hasonefield module which is very out of date but does 80% of what I am after, it would be amazing if it didn't take you off the page though and you could edit the fields within the parent page (Person).
there is a fork of simon's orginal has-one-edit module that is still available and composer installable, which does the logic for editing fields (or all fields) of a has_one relation. Install it running
composer require stevie-mayhew/hasoneedit:1.0.x#stable
Then you can define several fields of your has one relation, naming should be HasOneName-_1_-FieldName.
From the docs:
For example, say you have a has_one called Show and that has_one has a field called Title you want to edit. You'd add the field TextField::create('Show-_1_-Title', 'Show Title').
To add support to your own forms, you need to add the sgn_hasoneedit_UpdateFormExtension extension to your controller and call $this->extend('updateEditForm', $form) before returning the form to the template. Without this, the fields will not get populated with the values from the has_one though saving will work.
I've got a main content type: "tournament", and a number of complimentary content types, e. g. "news", "judges", "participants".
A piece of news may relate to one or more tournaments or not relate to any tournaments.
Node type: News
Has field: Relevant Tournament(s)
↓
Node type: Tournament
The relation between tournaments and news should be set when creating a piece of news: you write news title, news contents and tick the relevant tournaments. So it's the complimentary node type that has the entity reference field.
On each tournament's page there should be a block that displays news relevant to the displayed tournament.
What i tried:
Created a Block View and put it to tournaments' pages.
Added a Contextual filter that retrieves tournament's Nid from URL.
Added an EntityReference Relationship (either "Referencing or "Referenced").
Set Format Style to Unformatted + Rendered Entity.
Attached either of Relationships to the Rendered Entity Format Style.
Also tried attaching Relationships to the Contextual filter.
But i failed to achieve the desired result.
I found a guide that might be relevant to my issue. But i failed to understand it because it involves PHP-hacking and is very Commerce-specific.
Okay, i got it figured out.
It wasn't working while i was using the "Rendered entity" Format Style.
When i changed to "Content" format style, it started working.
A complete recipe for reverse Views Entity Reference can be found here: http://drupal.org/node/1724396#comment-6406274
You can also check http://drupal.org/project/content_dependency
It provides automatic reversed referrals previews of different entity types.
Maybe an obvious question/answer:
Did you add a the "Content:rendered node" field to the fields of your view? You can refer to your Entity Reference Relationship (either "Referencing or "Referenced") in this field.
This might do the trick.. Otherwise, good luck!
I have a site where there can be more than one node author. My solution to this is a custom user reference field called additional authors, added to my content type. So if three people wrote an article, the person who publishes it, enters the other two into this additional authors field.
The problem I have is the following:
I'm trying to create a page (with Views) with the listing of all author's nodes - these can be either nodes where he is author OR nodes where he is referenced under additional authors. I want the author to be specified in the url (mysite.com/people/john-smith), but if I use contextual filters in Views, I can't seem to find the option to use OR - e.g. take author ID from url and show nodes where he is author of OR nodes where he is under additional authors.
I don't see any problem here:?? why you don't add the 'authors field' to your fields?
If you don't find it by the normal way look for it in 'Relationships'
Goodluck
So if I have 2 custom content types book and review, I'd like a user(when viewing a specific book) to be able to create/attach a review to the book.
I've tried a few options.
1) Created a "create review" formblock and using panels made a custom node view panel for review, but I couldn't get the relationship to work.
2) I also tried overriding comments on the book type with the node type review, the problem with this is I'd like users to be also be able to comment on the book and I couldn't see the ability to add multiple comment types.
This seems pretty easy to do on node edit with node reference extension so I'm hoping this isn't a big ask.
You need nodereference and nodereference_url modules.
You can simply create a nodereference field in your review content type, and configure it with nodereference_url widget.
You partially answered your own question. With the nodereference module in D6 (or just references in D7), you can create a link in the same place 'add a comment' appears (the .links div) which says "add a review". This link is because "reviews" has a field called something like "book reference" which is a noderef field. This review will automatically fill in the field with the book where the user clicked the link and, depending on how you set the field up, send you back to the referenced node (book) or the new review.
You can find an interesting screencast there that show how to use Views Attach and Node Reference URL to do what you want :
http://mustardseedmedia.com/podcast/episode37
I have a parent/child relationship (based on the cck node reference field).
Recipe Group contains a node reference to the type Recipe. It's a 1 to many relationship.
What I need to do is create a view that displays the recipe group information, and then under it, the recipes that have been assigned to it's cck field.
So
RecipeGroup1 - Title
Recipe1, Recipe2, Recipe3
RecipeGroup2 - Title
Recipe4, Recipe5, Recipe6
etc etc
I've created the view to pull the list of recipe groups.. but I have no idea how to retrieve the recipes that belong to the group?
I've tried googling, but we are on a tight time line and would appreciate any assistance.
Thanks.
Take a look at http://drupal.org/project/views_field_view. It lets you combine two views (groups, recipes), inserting the recipes view as a field into the groups view. Using this, you can have as many fields as you want for the group.
You can use the Views attach module to associate a view with a specific content type and display that view on that content type's node page.
There is a webcast here that demonstrates how the module can solve a problem similar to yours.
However, the webcast assumes your nodereference CCK field is on the child content type and is pointing to the parent content type, not the other way around like you have it.
Instead of using the nid of the recipe group as an argument to the view (as shown in the video) you may be able to use one of the recipe group's tokens (the nodereference field referencing its children). You can see that option at 9:32 in the video.
Whatever you decide to do, I think Views attach will likely be your answer.
Include the cck reference node field as an output field to your view. After, you can 'rewrite the output of this field'.. so that it looks however you want.
add noderefernce field in to views fileds
select check box to group field result in node ref field settings
theme that field as you want