Interfere with a views result that defines the content of a block?

Created on 16 January 2025, about 1 month ago

Problem/Motivation

I have a block that is rendered as the result of a Block-like display of a View, when a node of a particular content type is rendered. I wonder whether I can use ECA to grab the result of the query that forms that views-display, handle it (in this case: remove those rows according to the logged-in user's list of ROLES) and return it back, so that the block has possibly less rows than originally.

is that possible?
(I couldn't find it in the community or youtube)

💬 Support request
Status

Active

Version

2.0

Component

User interface

Created by

🇧🇷Brazil marco aurelio rocca

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @marco aurelio rocca
  • 🇩🇪Germany jurgenhaas Gottmadingen

    That sounds like you're looking for a block condition, and that's available with this module .

  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇧🇷Brazil marco aurelio rocca

    Hallo, Jurgenhaas,
    I've been trying to use that module you mentioned, and it has its own issues... I'll soon add my problem there.

    In this present case, my original usecase was "can I manipulate que results of a view, so that a block showing the results of a query might not to show them all, but only those that I manipulate?" I was trying to purge some rows off the result, but I couldnt have the rebuilt list exhibited.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Ok, so, there are two different topics:

    Controlling whether a block is being displayed, can be done with block conditions. And that's contained in the linked contrib module.

    Controlling the result of an SQL query in views is something different and has nothing to do with blocks. It's about tweaking SQL to return a different result. As views only always return entities, this can be achieved by access control to entities. That topic is being discussed in 💬 Any way to apply ECA Access logic to query tags, as for Views? Active and probably already implemented in eca_access_control .

  • 🇧🇷Brazil marco aurelio rocca

    Thanks again!
    My tests here still stumble on something weird: will you confirm to me whether I should open this as a different issue? It follows:

    1. create new Model, where Event = ECA Block
    2. you give it a name
    3. you struggle with your conditions and use an action like RENDER: TEXT to give this block some content
    4. you go to /admin/structure/block/list/{themname} and find this block and manage to make it show up in some region of the theme
    5. you get the block's machine name
    6. if your conditions are not fulfilled, you use action = UNPUBLISH CONTENT BLOCK, giving the machine name of the block
    7. Things work well, so that the content you want to show up ONLY when those conditions are fulfilled DO show up ONLY under those conditions.
    8. you get happy and start it all over AGAIN, with NEW conditions and new content,
    9. you end up with 2 or more new blocks, which will go through different sets of conditions and, when those are fulfilled, different contents
    10. PROBLEM: THEY INTERFERE WITH EACH OTHER, in such a way that it seems that THE FIRST ONE returning a "disappear!" command, from that "action = unpublish content block", makes ALL OTHER blocks UNDER that failing one to FAIL TOO, making them disappear REGARDLESS of having fulfilled their respective conditions...

    Hope I got it well written, sorry if I did not...

    Any glance at that?
    Should I really take this into a new issue?

  • 🇩🇪Germany jurgenhaas Gottmadingen

    This really sounds like a different issue. If you open a new one for this it would be great if you could provide a sample ECA model which demonstrates the effect so that we don't have to rebuild all of it manually, when we're trying to reproduce the problem.

  • 🇧🇷Brazil marco aurelio rocca

    Ok, I'll do that, thank you!
    Guess this issue might be closed, since it ended up being a mess of "side-quests"... :)

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Here is the follow-up issue: 🐛 ECA Blocks interfere with one another!? Active

  • 🇩🇪Germany jurgenhaas Gottmadingen
Production build 0.71.5 2024