Problem/Motivation

I've got a taxonomy vocabulary A with a field_def referencing a term from another vocabulary B which has a field_abc referencing paragraphs.

In my taxonomy term template for vocabulary A I want to display the value of field_abc from the referenced taxonomy term:
{{ drupal_field('field_abc', 'taxonomy_term', term.field_def.value.0.target_id, view_mode, 'en', FALSE) }}

When the last argument is set to FALSE, it is supposed to disable the access check.
If I unpublish the term from vocabulary B which is referenced in my term from vocabulary A, anonymous users don't see the content of this field even if we said we didn't wanted an access check.

CommentFileSizeAuthor
#2 3399028-2.patch835 bytespradhumanjain2311

Issue fork twig_tweak-3399028

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

MacSim created an issue. See original summary.

pradhumanjain2311’s picture

Status: Active » Needs review
StatusFileSize
new835 bytes
macsim’s picture

Issue summary: View changes
macsim’s picture

#2 is adding more access check. It's not the problem.

The problem is : we should have no access check at all when $check_access is set to FALSE

Prashant.c made their first commit to this issue’s fork.

prashant.c’s picture

Adding $check_access to the condition. Please review.
Thanks!

macsim’s picture

Status: Needs review » Needs work

#7 won't fix the problem

There's no problem when $check_access is TRUE (that's what #7 is checking)

The problem is that when $check_access is FALSE the following code returns nothing when it should return a renderable array:

return \Drupal::service('twig_tweak.field_view_builder')
  ->build($entity, $field_name, $view_mode, $langcode, $check_access);
chi’s picture

Status: Needs work » Postponed (maintainer needs more info)

The access check parameter only applies to the entity being viewed. I this case it's a term from vocabulary B. It does not affect checking access for child entities (paragraphs). If it's not the case, please provide exact steps to reproduce. Preferably without involving contributed modules.

macsim’s picture

Component: Code » Documentation
Category: Bug report » Task

Then it works as designed

Perhaps the doc should be more explicit about that point

The access check parameter only applies to the entity being viewed

Swapped category from "Bug report" to "Task" + component from "Code" to "Documentation"
Feel free to close the issue if it sounds explicit enough for you.

anybody’s picture

Version: 3.2.1 » 4.x-dev

Please check if this is still relevant and use 4.x as target branch for Merge-Requests (MR) as that's the new development branch. Thanks!

macsim’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.