New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom properties to blocks #1791
Comments
The easiest way is to add a custom component with the new css class field and then use the standard image-block component from within it! |
Instead of just fixing something for the App.Blocks.GetByType<Piranha.Extend.Blocks.ImageBlock>()?
.Properties.Add(new SelectProperty()
{
Id = "Style",
Name = "Display",
Icon = "fa fas-fish",
Options =
{
new() { Name = "Full", Value = "col-12" },
new() { Name = "Half", Value = "col-6" }
}
}); This way properties is not bound to the implementation of the actual blocks, but rather something that is defined in the application using them. |
Awesome! Thanks |
Reopening issue as we’ll be using it to track the development |
I'm still new to the product, and still interested for now. I'm hoping to see this feature implemented. I was surprised to find it exists in principle for Whatever it is or becomes, I think it should be as lightweight db-wise as possible. Another table and 2 joins is expensive (if you are thinking "BlockProperties" table). The 'Fields' decoration looks pretty verbose in storage, IMO, on first glance. I guess in the Manager it is not really critical. Don't want a hit during regular Block materialization, obviously. There is an expense (perhaps unnecesary) to auto-type conversion (ColorField <-> string, e.g.). As an exercise, I'm dillying about with an I'm thinking it could be done simply with just a single [Region] object, a POCO, named "Properties", "Options" or what have you. Perhaps default values and text description attributes on the POCO properties and enum types. The Manager could perhaps then just iterate across the Region object's properties and build UI inputs for them automatically. Add a button and slide-out to access a Block Settings dialog. If attributes are required for POCO's then so be it. The POCO's would be stored in the DB as json per Block instance somehow, no doubt. In this case just one new DB field instead of a Properties table + map? Please advise. I'm almost motivated to try, but am too much a newbie. Example Idea'r (with kindest respect). All I need now is for the
|
Hello,
I've extended the block ImageBlock to add a custom attibute (css class name), but (obviusly) the field not appear on screen.
How to extend the component "image-block" for appear the field?
The text was updated successfully, but these errors were encountered: