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

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.

Related

IN_VND_ITM_XLS Excel to CI - New field added to CI does not get inserted

I have added a new field into the IN_VND_ITM_XLS component interface, (BU_PRICE_STATUS), which is in a SQL View already part of the delivered template, ITM_VND_UMP_CVW. I modified the view (Record definition) in App Designer to pull in the BU_PRICE_STATUS field and then modified the component interface and added this field.
When I regenerate the template in Excel, it populates the additional field fine, I select it as an input cell (along with the others I originally had) and I submit the data and return back the green OK status.
When I look online in PeopleSoft I see that the vendor data was created for the item, however the BU_PRICE_STATUS field is populated with a different value than what I specified on the upload. The default value listed on the field definition in app designer was what was populated, instead of the value I had entered for the upload.
Is there something else I did to modify for this to work? I know that when you run the Item Loader process, it uses a Message definition (IN_MST_ITM_XLS) so I wasn't sure if the message needed to be updated to? Thanks in advance.
2/27 EDIT:
I've found that the Component (for this component interface) - IN_MST_ITM_XLS uses a function called PRCSITEM within a Function library record - FUNCLIB_INEIP and this populates data in a staging table called PS_ITM_VND_UMPR_EC. I see that this table does not contain the field BU_PRICE_STATUS (which I didn't believe it would) so I'm thinking if the code/table can be updated to capture this field it would work. Hoping someone can suggest if I'm in the right area and what would need to be changed.

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

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.

Drupal 7 Views 3: Exposed Filters that search specific FIELDS

I'd really appreciate some help with this.
I'm trying to create two different exposed filters in Views. I currently have 6,000 nodes with 75 fields each inside one content type. I'm using a Page View with an exposed form in a block. I also have the Better Exposed Filters module installed.
The first one, I want to make a text box for searching terms, but have it only search my specified fields. I would have it search 3 fields (to do a search on the full name): First Name, Middle Name, Last Name. They are all in different fields. The only thing I've been able to make it search so far is EVERY TERM in a content type (where it searches every field, not just name). I did that by exposing this filter:
Search: Search Terms
The terms to search for.
The next filter I am trying to do is for the field "Graduation Class." It might be best to do search terms for this too (if I can figure out how to search ONE field, like above), but I was hoping to have a select dropdown that lists every Graduation Class. These classes in this field range from 1905-1972. When you click a year in this box, it filters the current results by that year.
This sounds pretty basic, but I can't seem to get it and would REALLY appreciate some help.
For your reference (if needed), here are the types of filters I can add. (Off topic: I'm actually not so sure what the ":format" ones exactly are). For the "Content:" filters, I'll only show the "Name" ones, because there are 73 others. Many of these filters are from the Feeds module, because that's what I used to import my nodes:
Content: First Name (field_cinfo_fname)
Appears in: node:cadet.
Content: First Name (field_cinfo_fname:format)
Appears in: node:cadet.
Content: Middle Name (field_cinfo_mname)
Appears in: node:cadet.
Content: Middle Name (field_cinfo_mname:format)
Appears in: node:cadet.
Content: Last Name (field_cinfo_lname)
Appears in: node:cadet.
Content: Last Name (field_cinfo_lname:format)
Appears in: node:cadet.
Content access: Access
Filter for content by view access. Not necessary if you are using node as your base table.
Content revision: Log message
The log message entered when the revision was created.
Content revision: Title
The content title.
Content revision: Updated date
The date the node was last updated.
Content revision: Vid
The revision ID of the content revision.
Feeds item: Import date
Filter on a Feeds Item's import date field.
Feeds item: Item GUID
Filter on a Feeds Item's GUID field.
Feeds item: Item URL
Filter on a Feeds Item's URL field.
Feeds item: Owner feed nid
Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.
Feeds log: Feed node id
Filter on a Feeds Source's feed_nid field.
Feeds log: Importer id
Filter on an importer id.
Feeds log: Log time
The time of the event.
Feeds log: Request time
The time of the page request of an event.
Feeds log: Severity
Filter on the severity of a log message.
Feeds source: Feed node id
Filter on a Feeds Source's feed_nid field.
File Usage: Entity type
The type of entity that is related to the file.
File Usage: Module
The module managing this file relationship.
File Usage: Use count
The number of times the file is used by this entity.
Page Title: Title
A Page Title alternative to the Node: Title field.
Search: Links from
Other nodes that are linked from the node.
Search: Links to
Other nodes that link to the node.
Search: Search Terms
The terms to search for.
I might be mid-understanding you but don't you want to use:
Content: First Name (field_cinfo_fname)
Content: Middle Name (field_cinfo_mname)
Content: Last Name (field_cinfo_lname)
as your filters?
I'm guessing your fields are text areas which is why you've got the :format options; 'format' is another column in the longtext field type so will be available (just like 'alt' and 'title' would be available for an image field type).
If I understand the question correctly, you've got three name fields and you want a single text box to search all three fields. The easiest way to do this is to combine those three fields into a single field that is not displayed but can be searched using an exposed filter. One option is to use the Auto Nodetitle module to make the node title a combination of the three names. (I do this a lot with personnel directories so that a given entry displays as Lastname, Firstname). Then you could search on a the node title in your exposed filter.
If using the title is not an option for your project, you could add another field to your content type, eg: full_name, and write a small module to implement hook_node_save that would simply fill in the full_name field with "first middle last" whenever a node is saved. Then remove the full_name field from the display and use it for your exposed filter.
re: graduation year: If you're using a "List (Integer)" field type, that should be no problem. If you're using a plain text field type, that makes things more difficult. If you are using plain text, you may want to redo the field so that you could do cool filters such as "graduated before 1950" type filters or using jQuery sliders to select a range of graduation years.
Hope that helps.

How to format email link in Drupal cck Computed Field?

I am trying to create in Drupal a cck computed field that copies an email address from a cck field in a "job post" node content type to this computed field in the "job application" node content type.
I have found the following code that works perfectly, when I paste it into the "Computed Code:" box in the cck computed field
// obtain node id from nodereference cck field that links
// the job application node to the job post node
$item_nid = $node->field_appl_position[0]['nid'];
//load and build the information from the referenced job post node
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
//get the email address from the cck email field in the referenced job post node
$item_email = $item_node->field_job_email[0]['email'];
//copy the email address to the computed field in the job application node
$node_field[0]['value'] = $item_email;
However, when I try to send an email using the content of the computed field nothing happens. I believe this is the case because the computed field is not formatted as a mailto link. I have tried to change the parameters in the "Display Format:" box in the computed field, but have not succeeded.
Can anybody please help? Thanks!
you can use the following Drupal API function to format your link:
http://api.drupal.org/api/drupal/includes--common.inc/function/l/6
so in this case the value for your computed field would be the following:
l('Mail me', 'mailto:'.$item_email);

Drupal Views: Get nodes with the same taxonomy as the current node

I have a Content-Type with taxonomy-terms. It's a select-list, so it can have only one taxonomy - at least of that vocabulary. Now I need to build a view that lists all nodes with the same taxonomy.
Thought that this wouldn't be too hard since it sounds pretty basic. Yet I can't get it working. Any ideas? I'm trying to avoid writing a module for this.
While this was technically possible with Views 2 as described in some of the other answers, Views 3 has this integration built in.
You can create an argument for the taxonomy term id and then choose "Provide default argument". This will then give you an option for "Taxonomy Term ID from URL" and "Load default argument from node page..."
This will allow you to take the taxonomy of a page and pass that as an argument to your view block.
Note: Views 3 is currently in Alpha 3 but in my experience is at a relatively stable state and I am using it on production sites. If it has features like the one above that you find useful please use it, test it and submit bugs/patches if you encounter any issues!
This answer works in Views version 2 or higher. First you need to install Views attach ( http://drupal.org/project/views_attach ). Please read about Views attach before proceeding further. Views attach is best explained by this video http://mustardseedmedia.com/podcast/episode37
Now we get to Views attach. Please enable the views attach module before proceeding. Essentially Views attach attaches a view at the end of the node. In our case our view will be a listing of other articles with the same term.
We will essentially need to "pass" the taxonomy term of the node to the view. Let the name of your Vocabulary be called MyVocab.
Steps to make the view.
Lets call the view display_other_articles_with_same_taxonomy.
Add a display of type Node Content (available after enabling Views attach). This is a display just like block and page displays but with special ability of attaching itself to the node.
Make the following settings in the Node Content Display
Node content settings
Node types: [select the content types you are interested in seeing the list of nodes with same taxonomy term]
Build modes: Teaser, Full node
Arguments: token
Show title: No
You should select Use tokens from the node the view is attached to under Arguments. Let the token be [term-id] This is the "ID of top taxonomy term". This is very important!! Essentially you are going to be passing the taxonomy term of the node from the MyVocab (See http://groups.drupal.org/node/11788#comment-38332). If it has the lowest weight, the taxonomy vocabulary will be the first vocabulary in the taxonomy section of your node edit form. Add an argument Taxonomy: Term Id.
Add the fields you are interested in e.g. Node: Title. Make sure the Node: Title is made into a hyperlink by ticking Link this field to its Node
So what this view is going to do is:
Take the taxonomy term from the MyVocab vocabulary in the Node that is currently being viewed
Pass that as argument to the view display_other_articles_with_same_taxonomy
List all the nodes that have the same taxonomy term as the node being displayed.
Thats it!
If you're using Views 3 (currently at alpha3 at the time of writing) and you want a block (right now the articles have same taxonomy term come at the end of node body) you can do it in the following fashion:
Forget about views attach... its not required
Add a block view. It should contain the same argument, fields and filters as the instructions above for the Node Content display.
You need to modify the settings for the argument Taxononomy: Term Id just slightly: Under Action to take if argument is not present: choose [x] Provide Default Argument. Choose [x] Taxonomy Term ID from URL. Now make sure [] Load default argument from term page is unselected and [x] Load default argument from node page, thats good for related taxonomy blocks. Also [x]Limit terms by vocabulary and choose the Series vocabulary.
Make sure you name the block and put it in the appropriate region.
Note: This answer is subset of the answer I provided at How to just show NodeQueue block on included nodes? In that scenario the requirement was that the related articles are explicitly selected and listed in a particular order. Its a little more complex and uses Nodequeues which we don't need here at all.
Use relationships
Node 1 -> Relationship 1 -> Term // This will be relationships->taxonomy->term
Term -> Relationship 2 -> Node 2 // This will be relationships->node->node
Argument NID to filter NODE 1
Fields or node full view on Relationship 2 (you will see select box on field adding form, to determinate what NODE to use)
Views gives you the options to add filters. Click the plus sign in the filters area of the views admin UI, select Taxonomy from the list, check either Term or ID, and fill in the value that you need to filter by.
EDIT (for explicit instructions):
First, add the necessary fields that you want under the fields section that you want to display from the nodes that you are trying to filter such as node title, etc.
Under Arguments, click the plus sign and select Taxonomy
Check Taxonomy: Term and click Add
Click Update
In your preview area test it out by adding an argument and clicking preview. If it doesn't work, your nodes do not have attached taxonomy, your views module is corrupted, or you didn't follow directions.

Resources