Ju99ernaut / grapesjs-template-manager

Template and page manager for grapesjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable blocks depending on the page

vizardkill opened this issue · comments

My brother wanted to bother you again, and I have a question.

Is it possible to disable certain blocks when I select a page?

image

Suppose I want to disable certain blocks when the user selects the checkout page, because there are blocks that cannot be used unless they are on a specific page.

image

I was thinking of running a command where I get the BlockManager but I haven't found any functionality within the API that allows me to disable the blocks

I don't think you can disable blocks, maybe you can filter out the blocks?

It can also be an option, I will give an example to understand what I want to achieve.

There are some blocks that are responsible for building the payment form at the time of completing a purchase for having added products to the cart.

In theory, the blocks that are part of the payment process should only exist when selecting the checkout page.

So we could:

a. Hide blocks visually

b. Disable blocks when changing a page using the BlockManager

c. Change the list of blocks every time a page is changed.

I don't think you can disable the blocks from the API, the only option I can think of would be to filter out those blocks each time you switch to such a page so that they don't appear in the block manager.

If that seems to be the easiest option, I was looking at the api and indeed there is no method to do it.

I will take a look to make the filter and I will tell you if I could solve it through the filters