I need help with this Drupal 7 situation:
I'm publishing travel agency offers using my own content type named "offer"
I'm storing information about hotels (descriptions, prices, photos, etc.) in taxonomy named "hotel"
I need to display relevant hotel info in each offer
And here is my problem. I've added a new term reference field named "field_hotel", but I only get a link to taxonomy term instead of actual content.
I tried to use this code, entity_load() runs fine, but I get "EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids()" error in field_view_field(().
$term = entity_load('taxonomy_term', array($hotel["und"][0]["taxonomy_term"]->tid));
$view = field_view_field('taxonomy_term', $term, 'field_hotel');
print render($view);
What am I doing wrong?
Thank you for your answers
Instead of storing hotel information in taxonomy terms, I'd suggest that you create a separate content type for hotels. That way, you'll be able to link offers to hotels using References, which is a much more flexible approach. That will also allow you to display hotel information on the offer page using Views.
Try replacing the second line with $view = taxonomy_term_view($term);
See documentation for taxonomy_term_view.
Related
There is a problem, I do not know how to solve it.
The scheme is as follows.
There are categories of goods, in this form:
Category-1(term_id=1)<br>
subcategory-1(term_id=4)<br>
subcategory-2(term_id=5)<br>
subcategory-3(name Tour)(term_id=6)<br>
Category-2(term_id=2)<br>
subcategory-1(term_id=7)<br>
subcategory-2(name Tour)(term_id=8)<br>
https://docs.gravityforms.com/creating-a-feed-for-the-advanced-post-creation-add-on/
Gravity Forms will initially look for the category/tag of the same name as specified and use that. If no match is found, then a new category/tag will be created. All new categories/tags created this way will be placed at the top level of the category/tags hierarchy.
I tried everything in the Populate Anything settings, I can’t get it to correlate with the category that I need.I need this (subcategory-2(name Tour)(term_id=8)), inserts here anyway (subcategory-3(name Tour)(term_id=6))
By the way, I'll add one more thing.
https://github.com/gravitywiz/snippet-library/blob/master/gp-populate-anything/gppa-display-terms-hierarchically.php
It would seem that he chose the category that is needed, how to force the search not by name, but by term id?
In wordpress I have a custom post type (generated through the ACF plugin) of job offers which include several text fields (meta_key values) which the plugin "post grid pro" will display no problem. However, I have one field which is the agency that posted the job offer.
This is a relationship field and whenever I add this meta_key to the list of fields to display within each block of my grid it displays simply "Array".
I have tried creating my own shortcode to display this field but alas, this does not work.
There is a page in the site, written by one of the original developers, which lists the job offers. They have managed to display the title of the job agency in php with:
<?= get_field("agence")[0]->post_title ?>
I would like to be able to either write my own shortcode to display the agency title or somehow dynamically create a new meta_key for each job offer which contains automatically the name of the agency derived from the relationship field "agence".
Any help would be vastly appreciated.
Instead of using the relationalship ACF field type, use the one called "Post Object". As long as you don't enable "Select multiple values?" option this will only return a single post object.
This post lists the difference between the two field types. Basically, they both return post objects, but they have slightly different options, and relationship fields always returns the result in an array. You could technically use the relationship field and set the minimum and maximum number of posts to 1, but the post object field is the most appropriate one to use when you only want a single post.
Can we call one taxonomy term from another as a parent and child relation for example I need to click on product category and that show me product series page and when I click on product each series that will lead me to actual product detail means node, so I have two taxonomies category and series I am about to click on category to carry me to series page and then to click on series page to carry me to product detail page on the concern series”
no codebase problem
i am expecting that these two taxonomies may be used as i have mentioned in the question summary but, i can't do it so i hope some help in resolving this issue
Let's look at this answer, I hope it will help you.
Taxonomy terms from the same vocabulary filtered and referenced on multiple content types
To do this you’ll need to have the Entity Reference module installed. So get that out of the way quickly with drush dl entity reference -y and drush en entityreference -y if you haven't already.
First up, we need the taxonomy set up.
Let's demonstrate with the help of an image.
You’ll notice that these terms could be more or less grouped into two categories: Transport and Sleeping. One term (couchette) kinda fits both criteria and is there to exemplify the reason for not using 2 different vocabularies to handle the issue. Now we need to technically make the distinction between these terms as well and since they are entities, we can use a field for that.
So we can now go ahead and add a new field to this vocabulary of the type List (text) with whatever widget you’d like (and let’s call the field Type). You should make the allowed number of values unlimited and put the following in the allowed values list:
Edit each term and select the appropriate type. As expected, for the term couchette, you should select both options.
Now that we have our taxonomy squared away, it’s time to create a View that will handle the filtering of these terms. Because if we now add the Tags taxonomy term reference field to our content types in the normal fashion (as it is already present in the Article content type) we’ll be able to select all the terms in the vocabulary for all the content types. And that's not what we want now.
So create a drupal 7/8 View that shows taxonomy terms of the Tags vocabulary - let’s call it Tags Filter. Add 2 displays of the type Entity Reference and a filter of the field we added to our terms earlier. So for instance the first display can show the terms which have Sleeping selected and the other one can show terms which have Transport. Save the View and you can close it.
Now finally we can edit our content types and add to each a new field of the type Entity Reference with a select list widget. For the target type select Taxonomy term and under Entity Selection choose the following: for Mode, go with Views: filter by entity reference view and then select the View in question - one of the two displays which we created earlier. In the picture below, I named one of the displays
I have a book in Drupal with 17 chapters, and several subchapters within them. I want to set up a filtered search that will let me restrict a search entry to only a specified chapter. I've labeled the chapters with a taxonomy vocabulary and using the custom search module, I have set up a search that lets you filter by taxonomy.
However, when I do this, the search doesn't work for the child pages associated with a chapter. For example, in using my method and searching chapter 1, I don't get any results from the subchapters in chapter 1. Is there a way to resolve this? Or do I have to set up my search in a different way?
You should change your filter to 'Has taxonomy terms (with depth)'
This will also include the child entities, or sub chapters in your situation.
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.