Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jan A 63 posts 268 karma points
    Feb 19, 2024 @ 15:42
    Jan A
    0

    Hijack the BlockGridItem render

    I use some rendercontrollers to make some code and template separation for some pages. The pages loads data from an external database and now I wonder if there any way to hijack the render of an blockgrid item?

    I know I can just place the code in the razor template, but I want to have as little code as possible in the razor and load models with all needed data.

    I tried to do it like I do for the page with a RenderController without success

    public class FollowOrderBlockController : RenderController {
    ...
        public async Task<IActionResult> FollowOrderBlock(FollowOrderBlock model)
        {
            var myData = await myManager.GetTheData();
            model.MyData = myData;
            return View(model);
        }
    }
    

    On some other places I have "solved" this by making a component and call that from the block.

    @(await Component.InvokeAsync("MyComponent"))
    

    But on this block that's not an option

    Is there a way to do this, or does this not get routed the same way?

Please Sign in or register to post replies

Write your reply to:

Draft