Active
Project:
Drupal core
Version:
main
Component:
taxonomy.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Jan 2011 at 09:15 UTC
Updated:
23 Jun 2020 at 21:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #4
swentel commentedtaxonomy_term_page() only looks for nodes. Users aren't probably classified as content. Could be easily done with views of course overriding the taxonomy term path.
Comment #5
rosk0I thought so too,but after about two hours of trying to do this(with different version of views) am still at the beginning with no result. could you help me please?
Comment #6
stevenpatzComment #7
Anonymous (not verified) commentedThere are perhaps multiple ways to accomplish this. They all will require writing a module I think, but in any case, you're going to be able to copy and paste code from Drupal 7 core and tweak it in simple ways.
You need to create a view or page callback that lists the entities that have this term value. Create a new formatter in your module that links to this view or page callback. Copy the code in taxonomy.module that's related to the formatter hooks:
taxonomy_field_formatter_info
taxonomy_field_formatter_view
taxonomy_field_formatter_prepare_view
Put these in the new module. Rename them. Cut out the formatter you don't want (the plain one) and hack around the one named taxonomy_term_reference_link. Instead of linking to entity_uri()'s return value, it needs to link to 'my-custom-view-of-users/'. $term->tid. Rename the taxonomy_term_reference_link when making your changes, too. It has to be named something besides taxonomy_term_reference_link. Then use this formatter for the taxonomy term field on your user entities.
There may be other ways, but they will always require a working view or page callback that takes the term as an argument. For example, i'd also investigate using hook_entity_info_alter() to add a new uri callback specific to the user entity and bundle. I don't know how that would work, but it appears at first glance to be possible.
Comment #8
rjbrown99 commented#7, we are now 8 months out from your advice. Do you still view that as the approach, or has a new module or functionality come along to provide that missing feature? I'm about to slog into term reference tied to users. If there is a shortcut I'd like to take it rather than writing a module :) Thanks.
Comment #9
cmacdonald commentedI'm up against the same issue, but I don't really have the expertise to write a new module. Are there any other workarounds for this that I could try?
Thanks.
Comment #10
cmacdonald commentedI ended up using the Profile2 module, and creating a drop down list field for my user types in the profile.
Then I created separate views for each user type based on the value of that field.
More work, but probably less than writing a new module.
Comment #11
skizzo commentedJust moving into D7 and I am facing the same problem. If I understand it correctly, provide term relationship via taxonomy term reference fields should allow to solve the problem with Views, without additional modules. Could someone please confirm my understanding? If so, please change this issue status.
Comment #12
xjmYes, this should be doable with views.
Comment #13
gaele commentedIt is not working as expected, so the design is wrong.
See:
#1361958: Profiles don't show up on Taxonomy Term pages
#1363526: Term reference field on non-node entity links to wrong page
Comment #14
joachim commentedThe design of taxonomy is that you tag content and list it. If you want to apply terms to other types of entity, then you need to either use the formatter that doesn't have a link, or do something else. In more advanced site designs, taxonomy isn't even shown, it's just used as dropdowns for filtering by and so on.
> Do you still view that as the approach, or has a new module or functionality come along to provide that missing feature? I'm about to slog into term reference tied to users. If there is a shortcut I'd like to take it rather than writing a module :) Thanks.
The shortcut is writing the module and sharing it on d.org for others to use and contribute to.
Comment #15
gaele commentedjoachim, please let others have a chance to have a look at it.
> The design of taxonomy is that you tag content and list it.
This is how it used to be in D6. In D7 the ability to tag other entity types was added. My impression is that the taxonomy term page was just left as is, without a conscious decision (but then again I may be wrong).
This probably won't get solved in D7. For D8 we need a more fundamental discussion about where a term reference field should link to (all entities, current entity type, ...). If nothing changes we need Drupal to not let people like the issue starter make mistakes and get unexpected results.
Comment #16
xjmIf this were the case, there'd also likely need to be indexes for non-node entities. See also #1040786: Include entities in taxonomy_index.
Comment #17
scottrouse commented+1 to this request.
It seems like an obvious oversight in D7 to me. What's the point of being able to add a term reference field to an entity other than a node if it doesn't show up on a taxonomy page? There would be no other benefit that I can see to choosing term reference over just an option list with a View created to filter on those options.
Comment #18
Sylense commented+1
Comment #19
xjmFor those adding +1 above, please do keep in mind this should already be doable with Views, which will provide flexibility and configurability that core probably won't. Edit: Also, I believe the fact that term listing pages list only nodes was a design choice for D7. That is why this issue is a feature request.
Comment #20
xjmI added this issue at #1347448: [META] Taxonomy admin usability Improvements since it does cause confusion, as the issues @gaele links indicate.
Comment #21
gaele commentedBased on #7 I have created a module that provides a new field formatter for a term reference field: http://drupal.org/sandbox/gaele/1377430.
After installing the module you will have a new format "Link (to custom path)" on the "Manage display" tab. Use this to specify a path to a view.
I have successfully used this module to link a term reference field on profiles to a view of profiles.
Note that this is still just a workaround. This should be fixed in a more fundamental way in D8.
Comment #22
joachim commentedI think that module is going to be tremendously useful no matter what core does -- think of times when you want terms from vocab A to link to view A, and those in vocab B to link to view B.
@gaele: if you don't yet have permission to create full projects, want to file a request for that sandbox to be reviewed? I'd be happy to review it.
Comment #23
skizzo commentedsee also entity_path
Comment #24
gaele commentedskizzo, thank you for the link to entity_path. I think it is more useful than my module. Though perhaps a bit more difficult to configure.
This is what I did:
1. create a view accepting a taxonomy term argument, configured as "Term name converted to Term ID".
2. install the entity_path module, go to admin/config/content/entity_path and "Add".
3. Instance: choose a vocabulary under "Taxonomy term (taxonomy_term)".
4. Path pattern: /[term:name]
5. Check "Space Separator" with Separator character "-", and Path case "Lowercase".
Comment #25
joachim commentedEntity path looks interesting, but I think doing it as a formatter covers more ground.
Consider for example the 'Drupal core version' vocabulary on d.org (when d.org is upgraded to D7... ;).
When applied as a term reference to project pages, it could link to a view of project pages; then applied as a term to documentation pages, it could link to a view of documentation. That is doable with field formatters because they are per-instance of the reference field, whereas with Entity path, a term such as '6.x' always links to the same place.
Comment #26
diskojerk commented@gaele #24
How did this method work for you? Did you get the expected result?
Comment #27
gaele commentedYes, Entity path is working for me. I'm using a vocabulary specifically for profiles: http://socialhistory.org/en/staff.
See joachim's remark for other uses. (If more people are interested in my module I will create a full project.)
Comment #28
skizzo commentedJohachim's remarks make sense. It seems to me that term_pages and entity_path do address different use cases. I tried your module from git repository: it works fine for plain taxonomies, but I couldn't apply it to my hierarchical taxonomies. Maybe a "Hierarchical Link (to custom path)" could also be provided?
Comment #29
j4 commentedPlease am not used to git. Can you post a zipped version of the folder here instead which I can download and try?
Thanks and yes I would like to add my vote that is facility is a must, if we are allowed to add term reference to profile types.
Thanks
Jaya
Comment #30
gaele commentedComment #31
joachim commentedRegarding linking your taxonomy terms to Views that list other things: I made this last week http://drupal.org/project/field_formatter_value_link
It could do with a patch to pass in the term ID rather than the term name. You could probably get Views to accept the term name though.
Comment #32
onelittleant commentedFor those looking to do this in D7...
This can be achieved with views and http://drupal.org/project/taxonomy_display in little time.
A bit more challenging is making the view you use to replace the taxonomy/term view show more than one entity type, though it can be done if you make the taxonomy term the base table and relate it to multiple entity types via a shared term reference field.
Comment #33
xjmWith Views being moved into core in Drupal 8, this issue will be fixed by that. We'll convert the taxonomy/term listing to a view, and then it will be possible to modify it to list other entity types. :)
For details, see: http://www.angrydonuts.com/vdc-update-and-announcement
Comment #34
joachim commented> We'll convert the taxonomy/term listing to a view, and then it will be possible to modify it to list other entity types. :)
Not really.
Views can have only one base table.
One cheat would be to use taxonomy term as the base, the term ID of what you're looking at as the argument, and then add a relationship for each entity type you want to list.
But then you couldn't sort them by post date or anything meaningful like that because you wouldn't have common table columns.
Then again, that bit wouldn't be possible with raw SQL queries either.
Comment #35
gaele commentedThe confusion for users still needs to be resolved. Let's keep this on the list at #1347448: [META] Taxonomy admin usability Improvements.
Comment #36
hoff331 commented@gaele #24
Can you please clarify "1. create a view accepting a taxonomy term argument, configured as "Term name converted to Term ID"."
Comment #37
gaele commented@hoff331: in the example below Department is a term reference field.
Comment #38
xjmClarifying the title.
Comment #39
johnvThe following issues have the same problem, but they propose different solutions. Hence, a more explicit title:
- this issue: #1016942: Allow taxonomy/term pages to list multiple entity types
- other issue: #1137558: Show multiple entity types on Core taxonomy/term pages, not just 'node'
Comment #40
marcingy commentedViews 3 is contrib what is in core is views so a reference to views 3 is pointless in the title, although the linked issues are useful.
Comment #41
joachim commentedViews can't mix base tables.
One possible -- but fairly ugly -- way to do this would be by making the taxonomy term be the base, and then add relationships to multiple entity types.
You'd then use the 'rendered entity' field (IIRC there is one), which you'd add once for each relationship, and you'd need to make sure that all the empty fields don't output anything.
Comment #42
coolhandlukek2 commented+1
Comment #42.0
coolhandlukek2 commentedAdded summary template headers
Added reference to other issue
Comment #43
jibranWell taxonomy/term page is converted to view in #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views. The query for the page is
In theory we can use other entities now but
taxonomy_build_node_indexis hardwired for node andtaxonomy_indexis infect taxonomy_node_index so we can't really use other entities. Perhaps after #1040786: Include entities in taxonomy_index it's possible so postponing it on #1040786 which I just moved to 8.1.x.Comment #45
heddnI don't think this needs to be postponed any more.
Comment #48
johnpitcairn commented@Joachim:
One possible -- but fairly ugly -- way to do this would be by making the taxonomy term be the base, and then add relationships to multiple entity types. You'd then use the 'rendered entity' field (IIRC there is one), which you'd add once for each relationship, and you'd need to make sure that all the empty fields don't output anything.This does not seem to be possible if one entity type is a node. To get any results for nodes the relationship needs to be required because of #1349080: node_access filters out accessible nodes when node is left joined.
Comment #49
ytsurkTo overwrite the default taxonomy/term/% view, the forum module uses a nice approach by providing a RouteSubscriber. #2010132: Canonical taxonomy term link for forum vocabulary is broken
Still the view then needs a relation using the desired field (taxonomy reference) ..
Comment #50
lukasss commentedSadly, that question stretches back to the 7 version
Comment #51
ytsurkThere are helping modules, fe. https://www.drupal.org/project/taxonomy_entity_index
Comment #52
lukasss commentedI need D8!
Comment #55
marcoscanoMarking #2978474: Taxonomy terms seem useless when used with media module as duplicate of this.
Comment #60
axel80 commentedI think now this is quite important, especially with Media in core