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.

Issue fork drupal-3225722

Command icon 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

diamondsea created an issue. See original summary.

diamondsea’s picture

Issue summary: View changes
diamondsea’s picture

StatusFileSize
new1.53 KB

Patch to change category.domain attribute to reference taxonomy vocabulary name, not term url

diamondsea’s picture

Issue summary: View changes
diamondsea’s picture

Status: Active » Needs review
diamondsea’s picture

Issue summary: View changes
diamondsea’s picture

Issue summary: View changes
gauravvvv’s picture

StatusFileSize
new1.56 KB
new861 bytes

Re-rolled patch #3, Attached interdiff for same.

diamondsea’s picture

Removed unused "use" statement.

hgupta28’s picture

Tested #9 Working as expected.

dzinkevich’s picture

Looks 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?

dzinkevich’s picture

Looks 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

dzinkevich’s picture

Sorry 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...

lendude’s picture

Thanks 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.

dzinkevich’s picture

Looks 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.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new170 bytes

The 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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.