I created a Block and Block Group. The Block Group is decorated with BlockItemType [BlockItemType(Type = typeof(DocumentBlock))]
, which is my custom Block. Following the Piranha documentation, I registered the Block and Block Group at StartUp.cs. The Block Group shows up in the Manager like it should and I can add it to my Page. However, when I click the "Add" button, nothing happens. It also breaks the Piranha Block Groups, like the ImageGallery (clicking the "Add" button does not work).
Has anyone experienced this with custom built Block Groups? Below is my code:
StartUp.cs
...other code omitted for berevity
// Initialize Piranha
App.Init(api);
new ContentTypeBuilder(api)
AddAssembly(typeof(Startup).Assembly)
.Build()
.DeleteOrphans();
// Configure Tiny MCE
EditorConfig.FromFile("editorconfig.json");
// Middleware setup
app.UsePiranha(options => {
options.UseManager();
options.UseTinyMCE();
options.UseIdentity();
});
App.Blocks.Register<DocumentBlock>();
App.Blocks.Register<DocumentGalleryBlock>();
DocumentBlock.cs
using Piranha.Extend;
using Piranha.Extend.Fields;
namespace Csw.Web.Models.Cms.Blocks
{
[BlockType(Name = "Document", IsUnlisted = true)]
public class DocumentBlock : Block
{
[Field(Options = Piranha.Models.FieldOption.HalfWidth, Placeholder = "Please select a document from the media library")]
[FieldDescription("The title of the document")]
public string Title { get; set; }
[Field(Options = Piranha.Models.FieldOption.HalfWidth)]
[FieldDescription("Choose the document to include in this block")]
public DocumentField Document { get; set; }
}
}
DocumentGalleryBlock.cs
using Piranha.Extend;
using Piranha.Extend.Fields;
namespace Csw.Web.Models.Cms.Blocks
{
[BlockGroupType(Name = "Document List", Category = "Media", Icon = "far fa-file")]
[BlockItemType(Type = typeof(DocumentBlock))]
public class DocumentGalleryBlock : BlockGroup
{
[FieldDescription("Optional heading that will display at the top of the list.")]
public StringField Heading { get; set; }
}
}