Drupal views 3 - missing "MULTIPLE FIELD SETTINGS" in entity reference - drupal

Context: Content type Person has reference (multiple values) to a content type Work, using entity reference.
Need: To display the title of each person node which references a given work, separated by a comma.
Done: A view with a back reference, the right nodes are fetched. (Views 7.x-3.7)
Problem: Cannot display the value separated by a comma. Note: I usually do it with the "Simple separator" display type which is under "Display all values in the same row" in the MULTIPLE FIELD SETTINGS field group. However, this field group is not available in my context.
Solved
I have found the module Views Merge Rows - works very nice. If it does not support Features module for some reason, I can take some of its code code in order to use hook_views_pre_render myself.

I was able to work around this problem by using token_formatters. The basic steps (after token formatters is installed):
No relationship to referenced entity in views (not needed)
Add the entity reference field to the view
Change formatter to "tokenized text"
For 'Text to output' use a token (I'm using [node:field-name])
For 'link destination' use a token ('m using [entity:url:path] for a relative link)
Set multiple field setting as desired

You need a custom views Format here because you are talking about the whole views-row not a multiple results field. You can use the "Unformatted list" and add a comma to be added with CSS or JS.
What kind of Relationship do you use? Can you export your whole views in an external editor and provide a link?

I had a similar issue, where I was using the Entity Reference relationship of "Referencing Entity" instead of "Referenced Entity". (The reference was on the child and the View started at the parent level).
When you run a Drupal System Message on the row (dsm), it returns all the nid responses appropriately, but as different result rows instead of as a single object; however, since the NID field (like many others) has no option for display multiple results, it would only grab the first result.
I ended up having to do an Entity Query from a Views PHP field with the current row's NID as one of the Field Conditions. That seemed to do the trick, rather than trying to load a View inside of a View with views_field_view.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', '[your_content_type]')
->propertyCondition('status', 1)
->fieldCondition('[your_field_machine_name]', '[field_column_to_check]', $row->nid)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();

I had a very similar problem: no "Multiple Field Settings" were available in the field configuration of a multi-value entity reference from my content type to User.
Solved it by removing the entity reference and instead using the multi-value "User ID" field of my content type directly. The "Multiple Field Settings" form area was available now and I selected "Display all values in the same row" there as you do normally. Now this would only display numeric user IDs separated by comma (not desired). But in the field configuration there was also a setting "Format:", which I set to "Label". This would display user names instead.
So I guess by creating a custom formatter you would be able to display your associated "Work" entities in a similar way.

Related

MS CRM 2013 Process Update Account - multiple values to one field

I'm trying to implement an update procedure like the one in this blog post (via extra entity and workflow updating account, triggered when the new entity is being created)
http://www.powerobjects.com/2013/08/01/updating-records-in-microsoft-dynamics-crm/
In my list and the new entity "Account Update" I have 3 fields for the full name of a company (name, name_2, name_3).
In my workflow I want to put these 3 together and combine their values in the Account field "Company" (the company's name).
In the process I tried to insert them via the "Form Assistant" and in the field "Company" I now have the following entry:
{Name(Account Update);Name_2(Account Update);Name_3(Account Update)}
but it doesn't seem to work. After my import and update of the account (which ends successful) the value in "Company" is only the value of the first name field.
Is it possible to combine values?
What exactly does it do, when I choose more than one field in the Form Assistant and say OK?
So at last I figured out how to archive it.
With the "Form Assistant" you can combine or add multiple field values to one new field but it is a bit tricky.
The value in the process update the properies have to look like this:
{Name(Account Update)} {Name_2(Account Update)} {Name_3(Account Update)}
BUT
It does not work if you enter this as text, you have to add the fields one after another so that they are recognized as fields (and marked yellow).
Click into the field (here: "Company").
Then choose the first field in the Form Assistant. Click "Add", choose it in the list below and click "OK". Now the field is in the field "Company".
Now go behind the end of the text in the field make a space and then choose and add the second field (clear the list in the Form Assistant before so that now only the second field is in the list)
So it's right if it looks like:
{Name(Account Update)} {Name_2(Account Update)}
Wrong if looks like following (happens when you keep the first field in the list before adding the second with "OK")
{Name(Account Update);Name_2(Account Update)}

Drupal 7: In Views, how could I order/sort in this manner?

Say for example I am printing name tags for thousands of content nodes in one content type called “Attendee.” Each of these nodes specifies a single "Attendee" for an event, (and their respective name tag). Say these attendees also needed name tags printed out for their “friends” who are attending with them. That is no problem—these “friends” obviously need their own node with the same fields to get their own name tag, so I distinguish that they are a “Friend of an Attendee” with a simple checkbox.
Now here’s the sorting order / grouping problem: When rendering the view, I need these “friends of attendees” to appear “right after” the attendee they are going with. Is there a way for me to maybe create a new autocomplete text field to link these together and then have them output next to each other?
p.s. I am technically using the Views PDF module, but it has the basic Views functions, so if it's possible with Views, it will probably be possible with this module.
In order to group these together, you have to have some way of linking friends to the attendees. You can do this by adding an entity reference field to the content type. See https://drupal.org/project/entityreference
here are the steps:
from admin/structure/types select "manage fields" on your content type
on the "manage fields" tab, click in "Add new field", and type in a label name. say "friend of"
for "type", select "Entity Reference", and for now, choose "Autocomplete" for your widget
click save
in the field edit tab:
select Target Type: Node
under Entity Selection, set Mode: Simple
set Target bundles: ( your attendees type )
click save
go to admin/config/development/performance and clear all caches
You should now see an autocomplete field when you edit an attendee that you can use to set the friend relationship
Things normally get a bit complicated now, as you have to tell views about the relationship between attendees and their friends. If you want to keep this dead easy, you can set the primary attendees as their own "friend" ( who they are going with ) so that you can group them together easily with their companions, without having to worry about contexts, relationships, or any other fancy stuff.

how to update 2 content types at once?

i use content_profile and i altered some of other content type cck fields from other module, when user submits the combined form how do i make it to update the 2 content type fields?
for example:
i got content type named "auction_items" and other content type named "auction_item_value"
in the content type "items" i got fields like "item name" , "brought before X days" etc... and in "item_value" i got fields like "this ad sale price" etc..
(its just for example)
i want that when user do new node for auction_items it will get also the fields of the node "auction_item_value , and once he submit it it will update two of the nodes
hope you understand
You could either code your own module and implement the hook_nodeapi to do your processing or use the Rules module which enables many operations which could involve loading related nodes and updating fields. Check drupal.org for documentation on either approach.

Error in copying the content of a cck field between 2 nodes using cck computed field

I have two content types (job_post and job_application) linked using the node reference + node reference url nodes. When I click a link in a job_post node, a new job_application node is created, so that candidates can fill out their job application. My goal is to automatically copy the content of an cck email field from the referenced job_post node to a cck email field in the job_application node.
To achieve this, I am trying to use a cck computed field, as suggested in: http://drupal.org/node/298951.
In my computed field I have placed the following code:
$node_field[0]['value'] = db_result(db_query("SELECT field_emailfieldjobpost_value FROM content_type_job_post WHERE nid=%d",$node->field_referencefieldjobapplication[0][nid]));
where the field_referencefieldjobapplication, is the node reference field in my job_application node.
In the display format box of the computed field I have:
$display = $node_field_item['value'];
I have selected the option to store it in the database as a varchar.
However, nothing seems to happen. I never see the cck field or its content both when I create or after I save a new job application (I have even tried to see it in views and failed). Any suggestion on what might be wrong?
Thanks
What I would do, is give a parameter with the link (the id of the job_post). and catch the parameter and place it in a disabled cck field.
Then write a module using the hook_node_api when a jobapplication is saved, you get the data from the job_post (using node_load) and use the data from the job-post however you want.

Create list of nodes that are referenced at least once

I'm sure this is simple with the Node Relationship module but I can't wrap my head around it.
I have a list called 'Comedian Profile' which has a node reference field for it. You then make - you guess it - profiles for comedians. To make an 'Events' (that doubles as an Ubercart item) you select the comedian. It then creates a view in the profile that lists all of that person's upcoming events.
Now what I need is an listing that shows in order of the date field each comedians name that is referenced(I'll worry about the other fields later). Note that the name is the referenced term.
Is this the right approach? If so could someone point me in the right direction or suggest a better way?
If I got it right, you can accomplish this using views relationships.
Add the field "Comedian" of the Event content type as a Relationship in the view (be sure to check the "Require this relationship" box). Then, add the fields, selecting the relationship you created. If the "Comedian" field is optional, check the "Hide if empty" box.

Resources