0

I am using the EVA: Entity Views Attachment module to create a view of content by author, to attach it to each author's user page. So, for example, when viewing /user/1, I will see a list of all the content created by user #1.

I've been able to do this successfully, but too successfully: Not only does this list show up on the author's user page, but it also shows up on every single piece of content that user has written.
Obviously, I don't want it to show up there.

How can I fix this, so that it only shows up on the user page?

These are my settings.

  • Entiti content settings
    • Entity type: User
    • Bundles: User
    • Arguments: id
  • Contextual filters
  • Content: Author UID
    • When the filter value is not available
      • Provide a default value: Type: User ID from route context

I'm working with Drupal 9, if that makes any difference.

2 Answers 2

1

I haven't used this module, but according to the project page:

The placement of the view in the entity's content can be reordered on the "Field Display" administration page for that entity, like other fields added using the Field UI module.

So you should be able to configure this at Manage Display for users: /admin/config/people/accounts/display. You can customize the display separately for Default and Compact, and you can create more view modes (different display configurations) as necessary.

Another way to do what you're doing (attach a view to users only on the user page) would be to use Layout Builder, which is included standard with Drupal.

  1. Make a view that shows the user's content with contextual filters in a block.
  2. Enable Layout Builder module.
  3. On /admin/config/people/accounts/display, check Use Layout Builder, open Layout Builder, and then add the block.
6
  • Thanks. I'm not very familiar with Layout Builder, I've just enabled it, and checked the "Use Layout Builder"... but how do I open "Layout Builder"? I'm not finding where to do that.
    – James Dunn
    Commented Mar 9, 2021 at 5:46
  • Oh, never mind, I see the "Manage Layout" button. Thanks!
    – James Dunn
    Commented Mar 9, 2021 at 6:02
  • Hmmm, so, update. Still can't get it to work with Layouts. If I just make my view a regular block, and then add it to the user's page with Layouts... nothing shows up. And if I use Eva, then it shows up in both the User page and each Node page. It's like I can't win.
    – James Dunn
    Commented Mar 9, 2021 at 7:18
  • @JamesDunn For the block shown with Layout Builder, if nothing appears, you probably have the contextual filter configured wrong. To test this, add a Text area block to the No results behavior area on the view's admin screen, or change Provide default value in the contextual filter options to User ID from logged in user and test while logged in. Commented Mar 9, 2021 at 7:23
  • For EVA, you should see the EVA view on the field management screen (/admin/config/people/accounts/display) as well as within Layout Builder when you have that enabled, so you should be able to modify where it is shown that way. Commented Mar 9, 2021 at 7:24
0

In addition to the other answers you could (for the single user page) provide a single twig template in your theme and then exclude the field from rendering (with the "without" twig filter function).

https://www.drupal.org/docs/theming-drupal/twig-in-drupal/filters-modifying-variables-in-twig-templates

2
  • Since the OP is using a view and the EVA: Entity Views Attachment module, in which way would a template file help him? Keep in mind that link-only answers aren't considered answers.
    – avpaderno
    Commented Mar 11, 2021 at 13:31
  • As far as I understand the question, the OP want's that the field is getting rendered only at one single page. The EVA view is rendered as a field in node display. So the OP could define a twig template only for the single page the EVA field is wishing to be displayed in.
    – dercheffe
    Commented Mar 11, 2021 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.