You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementing a site with tons of blocks and sometimes forgetting to register a block and then debugging the error for hours so I'm trying to implement the subject in the Sturtup.Configure method:
foreach( Type block in typeof( Startup ).Assembly.GetTypes( ).Where(
t => typeof( Piranha.Extend.Block ).IsAssignableFrom( t ))){
MethodInfo method = typeof( AppBlockList ).GetMethod(
nameof( AppBlockList.Register ) );
MethodInfo generic = method.MakeGenericMethod( block );
generic.Invoke( App.Blocks, null );
}
it seems working as viewing already existing pages renders its blocks, but in the manager, when trying to add a block to a page, there are no blocks at all, not even native ones, like Content, Image and so on.
After returning to traditional registration it throws the following exception when trying to load a content page:
InvalidOperationException: Block parent is missing
The problem seemed to be a basic block with no attributes that didn't need to be registered before switching to auto-registration. After adding the BlockGroupType attribute to this block, Piranha was able to handle it correctly.
Not quite. There was a non-abstract base class BlockGroupBase without any BlockGroupType attributes like BlockGroupType, inherited from Piranha.Extend.BlockGroup, which inherits from Piranha.Extend.Block . There was no necessity to register it with Piranha.App.Blocks.Register. After filling the database with some inherited from BlockGroupBase blocks and then switching to automatic block registration, BlockGroupBase was accidentally registered. After that, the problem started to appear. After adding the BlockGroupType attribute to the BlockGroupBase class, the problem disappeared. Perhaps it should be excluded from automatic registration with attribute filtering.
Implementing a site with tons of blocks and sometimes forgetting to register a block and then debugging the error for hours so I'm trying to implement the subject in the Sturtup.Configure method:
it seems working as viewing already existing pages renders its blocks, but in the manager, when trying to add a block to a page, there are no blocks at all, not even native ones, like Content, Image and so on.
After returning to traditional registration it throws the following exception when trying to load a content page:
InvalidOperationException: Block parent is missing
Only database restore is helping in this case.
Also tried to invoke
without result.
The text was updated successfully, but these errors were encountered: