Drupal taxonomy with reference entity field to itself endless loop - drupal

In my Drupal 9 installation I have an content type job, that has a field_location that is an entity reference to a taxonomy location. This location taxonomy has a field_neighbours that is also a entity reference to a list of location (basically itself).
In plain words: a job says its in Antwerp and Antwerp says its neighbours includes eg Brussels. Brussels in its turn says its neighbours include eg Antwerp. Or Brussels points to Antwerp and Antwerp points to Brussels.
When editing a job and pressing save this seams to create an endless loop as the browser just keeps loading (hanging) and the update is never saved.
What would be the best way to solve this issue?

Related

Save selected regions on jvectormap

I am using jVectorMap. this is exact concept used in my program. please check link first.
this is my test map link (cant upload here) http://test.rst-mt.com/Screenshot.png
I want to save/hold on name of the region. it is basically ticket system where i am selecting seats(multiple select is allowed). I want to process this with php and mysql(selected seats and pricing). so i want a way to know what i have selected so that can be read by php and i can process it.

Drupal 7: Use current node id to dynamically generate link on page?

I'm building an artgallery using Page Manager and Panels in Drupal 7.
A piece of art in the gallery is a node type and each one is related to a period of time, which is also a node type.
When viewing a page displaying a period of time, I need a link that takes the user to all the pieces of art relating to that period of time.
So I have made a view, that uses the nodeid of a timeperiod as a contextual filter, and gets all the artwork nodes, that are related to that particular timeperiod node.
The question is, when on the page for the timeperiod, how do I grab the nodeid of that particular timeperiod and dynamically generate a link to a page where the current nodeid is passed as an argument? (So that the correct pieces of art are fetched with the view).
You can use arg(1) in a piece of custom code to get the current node id (but only if it is a node you're on). See http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/arg/7. For instance you could easily embed your view in a template of your choice or a within a theme function like this:
views_embed_view('name_of_your_view', 'display_name', arg(1));
where the third parameter is the argument, the node id of your current (timeperiod) node. See http://api.drupal.org/api/views/views.module/function/views_embed_view/7.
To just place a link on that timeperiod node to that page (generated by your view) you would probably use a preprocess function in conjunction with a template (print if set). The possibilities there are uncountable, so you might need to provide further informations, where to place the link. But basically it can be achieved by using `arg(1)'.

Create a Drupal view that loads all articles that share any one taxonomy term (Contextual Filters)

I have a custom article type that contains a list of taxonomy terms
For example articles can be tagged with a location and possibly multiple topics.
On any given article's display page I would like to be able to pull a single view that gives a list of other articles that share any of of the taxonomy terms.
If an article was tagged with the topics of recipes & chicken as well as the location of new york I would like my single view to present the five most recent articles that share any one of the above tags.
The taxonomy terms have been added to the articles in the form of new fields of either the "Term reference" or "Node Reference" type. (field_topic, field_location)
I know that I have to somehow use a Contextual Filter, but I am having some trouble figuring out how to set and debug my "default argument".
I suspect that I've got to choose:
Taxonomy term ID from URL
Load the default filter from the node page
Do something with PHP code
I'm really struggling to get this displaying anything, and I can't even see a way to debug to find out what the values I'm getting are.
Can anyone help figure this out? Even some guidance on the right direction to look would be welcome at this point.
You can do this in just clicks if you have Drupal 7 and Views 3 (You already have this I'm sure).
Your configuration is correct so far.
Choose " Provide default value " as action to take if arg is not given.
Choose Term ID from URL"
Check "Load default filter from node page, that's good for related taxonomy blocks"
:)
this will load term IDs from the current node's term reference field if arguments are not given.

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.

Drupal: Views Grouping Issue

With CCK, I've added a field to the basic "Page" node type called "Resource Type". There are four possible resource types to choose from, in a dropdown, "Training, News, Research, Tools".
I've created a view that should group the nodes by their resource type. I've created 8 nodes, 6 of which are of type "Training", 1 is of type "Tools" and 1 is of type "News". Drupal is outputting the following:
Training
- Training Node 1
- News Node 1
- Tools Node 1
- Training Node 2
- Training Node 3
Tools
- Training Node 4
News
- Training Node 5
Research
- Training Node 6
When I tested with only 1 node per resource type, it displays as expected:
Training
- Training Node 1
Tools
- Tools Node 1
News
- News Node 1
I saw the other posting where the Devel module can screw up the output, but I'm seeing the above while the user is logged out (and therefore Devel is disabled for anonymous users).
Any idea what could be going wrong? My view is set to be an "HTML List", grouped by "Resource Type".
Not 100% sure, given that I do not have your setup to make tests, but it looks like you are experiencing this issue. On comment #16 Merlin of Chaos (the author of views) provides a patch that subsequent comments seem to confirm as "working".
If that is not the case, a workaround could be for you to sort nodes instead of grouping them. You could add the grouping header by passing to the template also the node type value: you then would add the header with the type of content by comparing with the previous one. In pseudo-code:
$type_in_use = 'xxx'
if $type_of_next_node != $type_in_use then
$type_in_use = $type_of_next_node
print_header($type_in_use)
Just an inelegant workaround, but should work!
HTH

Resources