Hide/Show block property doctype based
# help-with-umbraco
a
Hello, am just wondering if someone here can guide me 🙂 What i want to achieve is that a property in some blocks shows for editors based on the doctype they will be created, Description: The block type has a property for size If i create a block in article pages, size Property shows for editors. If i create the block in standard page , size property is hide for editors. Any tips? 🙏🏽 thank you in advance.
p
@User May I suggest “folks” instead of "guys"? We use gender inclusive language in this Discord 😀
c
p
@User May I suggest “people” instead of "guys"? We use gender inclusive language in this Discord. 😀
c
See above!
a
I guess my question took a different way 🤣
a
Its a bit tough I think, but youll need to create both variations of the block and add them in your block grid/list
Then the complex part, is in code you either hide or show the correct block. You can use something like this for it:
Copy code
builder.WithCollectionBuilder<ContentTypeConfigCollectionBuilder>().Add(() => builder.TypeLoader.GetTypes<IContentTypeConfig>());
Then youd need to make configtypes for the different types where you say, for type X (NewsPage for example), you can use these IPublishedElements (the blocks)
I hope it gives some pointers
4 Views