Problem/Motivation
When creating an RSS Feed containing a RSS category formatter on a taxonomy field, the category tag's domain attribute has the wrong value. The domain should identify the taxonomy vocabulary, not the term.
Reference: https://www.rssboard.org/rss-profile#element-channel-category
Steps to reproduce
Creating a Content view with a Feed display in a view with a Format of RSS Feed .
Have the feed display a node with a taxonomy field set with a field formatter of RSS category (this can be set in the content type's View Display under the RSS display mode).
Preview the RSS feed in the view, and the category fields will be included, but the domain will incorrectly contain the URL of the individual term, not the vocabulary the term belongs to:
<category domain="http://example.lndo.site/taxonomy/term/265">Therapeutics</category>
<category domain="http://example.lndo.site/taxonomy/term/218">Collaboration Sought</category>
<category domain="http://example.lndo.site/taxonomy/term/237">Oncology</category>
<category domain="http://example.lndo.site/taxonomy/term/231">Immunology</category>
The tag should contain a reference to the taxonomy, not the term, so that terms from the same vocabulary can be properly identified, such as this:
<category domain="/taxonomy/application">Therapeutics</category>
<category domain="/taxonomy/collaboration">Collaboration Sought</category>
<category domain="/taxonomy/therapeutic_area">Oncology</category>
<category domain="/taxonomy/therapeutic_area">Immunology</category>
In particular, note how this format allows the Oncology and Immunology terms to be associated as two terms within the same therapeutic_area vocabulary. This is not possible in the current implementation with links to the term URL.
Proposed resolution
Change the domain value from the term path to the vocabulary name (including /taxonomy/ prefix to allow future use of other domain types without conflict), eg:
<category domain="/taxonomy/application">Therapeutics</category>
<category domain="/taxonomy/collaboration">Collaboration Sought</category>
<category domain="/taxonomy/therapeutic_area">Oncology</category>
<category domain="/taxonomy/therapeutic_area">Immunology</category>
Remaining tasks
Update Unit Tests (if applicable)
User interface changes
No interface changes.
However, a useful feature would be to add a text field for "Domain" that can be overridden in the field formatter configuration of the RSS category formatter.
API changes
None
Data model changes
None
Release notes snippet
Update RSS Feed's category tag's domain attribute to properly identify vocabulary names.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3225722-nr-bot.txt | 170 bytes | needs-review-queue-bot |
| #9 | update_rss_category_domain-3225722-9.patch | 1.8 KB | diamondsea |
| #8 | 3225722-3_8.txt | 861 bytes | gauravvvv |
| #8 | 3225722-8.patch | 1.56 KB | gauravvvv |
| #3 | update_rss_category_domain-3225722-3.patch | 1.53 KB | diamondsea |
Issue fork drupal-3225722
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
diamondseaComment #3
diamondseaPatch to change category.domain attribute to reference taxonomy vocabulary name, not term url
Comment #4
diamondseaComment #5
diamondseaComment #6
diamondseaComment #7
diamondseaComment #8
gauravvvv commentedRe-rolled patch #3, Attached interdiff for same.
Comment #9
diamondseaRemoved unused "use" statement.
Comment #10
hgupta28 commentedTested #9 Working as expected.
Comment #11
dzinkevich commentedLooks good except you're hardcoding the taxonomy bundle link. Is this something that is standardized? I tried looking up a /taxonomy/ link on a site that I'm working on and it's not found.
I don't think it's usual that all vocabs have links - maybe there's a tags page, but that's not always going to be at /taxonomy/tags. How would you determine if the link is valid or not?
Comment #12
dzinkevich commentedLooks like you can go from $entity->getEntityType() to get the bundle definition, but on https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... I don't see any way to get a link for the type.
Is it wrong that it links to the term? Probably, right? But I'm not sure what other link it could use by default. In your case, the link should probably be something custom, perhaps something using the '/taxonomy/' root with tokens
Comment #13
dzinkevich commentedSorry for the reply spam - but looks like if you can get the vocabulary, it does in fact have a toLink() method: https://api.drupal.org/api/drupal/core%21modules%21taxonomy%21src%21Enti...
Comment #14
lendudeThanks for working on this! Just dove down the rabbit hole a little....
Looking at the docs pointed to in the IS, this doesn't need to point to a URL at all. And as @dzinkevich pointed out, a vocabulary doesn't always have a URL (not one that is reachable anyway).
Wouldn't it be easier to just use the vocabulary ID? If the sole purpose of this is to group things, that should do the trick right?
As per usual, I find the RSS documentation to be severely lacking as to what is right and what is wrong here. The examples are also very limited. I don't think what we are doing currently is wrong, it's just not very helpful/useful. The docs say something about the domain needing to be the provider of the categories, but nothing points to anything real, so go figure what that means ¯\_(ツ)_/¯
Tried to dig a little into the history of this to see if there was ever any discussion about the domain in previous issues or when this was added. It was added back in #872488: Regression: no way to get taxonomy tags into RSS feeds, but apparently it was removed previously so digging deeper became harder. I see zero discussion about the domain on that issue, so I'm guessing nobody knew or cared enough.
If somebody can provide some working examples of how this is used by other RSS feeds in the wild, that actually work, that would probably help determine what the right way to fix this is.
Comment #15
dzinkevich commentedLooks like there are a few options to go forward here:
1) Extend core so that vocabularies can have canonical views and therefore links
2) Tweak Brian's patch to call a hook to override the original domain link, and then either a contrib module to enter this, or a hook implementation.
3) Allow a custom link pattern with tokens, and implement a way to enter this in the views ui
4) Leave Brian's fix as-is, but don't commit it to the repo, and those who want to use it can.
5) ??? something else ???
#3 or #1 seem like the most resilient options, to me at least.
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.