Last active
July 22, 2025 15:57
-
-
Save joezimjs/171f50600ec9a16b5ea59bfdacdac574 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string fileAssetManagerBlockTypeGuid = "535500A7-967F-4DA3-8FCA-CB844203CB3D"; | |
const string heightModeAttributeGuid = "67ECB409-F5C5-4487-A60B-FD572B99D95B"; | |
// Attribute for BlockType | |
// BlockType: File Asset Manager | |
// Category: CMS | |
// Attribute: Height Mode | |
RockMigrationHelper.AddOrUpdateBlockTypeAttribute( fileAssetManagerBlockTypeGuid, SystemGuid.FieldType.SINGLE_SELECT, "Height Mode", "HeightMode", "Height Mode", @"Static lets you set a CSS height below to determine the height of the block. Flexible will grow with the content. Full Worksurface is designed to fill up a full worksurface page layout.", 2, @"static", heightModeAttributeGuid ); | |
Sql( @" | |
DECLARE @BlockEntityTypeId INT = (SELECT [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.Block') | |
DECLARE @BlockTypeId INT = (SELECT [Id] FROM [BlockType] WHERE Guid = '535500A7-967F-4DA3-8FCA-CB844203CB3D') | |
DECLARE @HeightModeAttributeId INT = (SELECT [Id] FROM [Attribute] | |
WHERE [KEY] = 'HeightMode' | |
AND [EntityTypeId] = @BlockEntityTypeId | |
AND [EntityTypeQualifierColumn] = 'BlockTypeId' | |
AND [EntityTypeQualifierValue] = CAST(@BlockTypeId AS VARCHAR)) | |
DECLARE @IsStaticHeightAttributeId INT = (SELECT [Id] FROM [Attribute] | |
WHERE [KEY] = 'IsStaticHeight' | |
AND [EntityTypeId] = @BlockEntityTypeId | |
AND [EntityTypeQualifierColumn] = 'BlockTypeId' | |
AND [EntityTypeQualifierValue] = CAST(@BlockTypeId AS VARCHAR)) | |
DECLARE @BlockId INT | |
DECLARE @IsStaticHeight VARCHAR(50) | |
DECLARE @TheValue VARCHAR(50) | |
DECLARE block_cursor CURSOR FOR | |
SELECT [Id] FROM [Block] WHERE BlockTypeId = @BlockTypeId | |
OPEN block_cursor | |
FETCH NEXT FROM block_cursor INTO @BlockId | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
SELECT @IsStaticHeight = [Value] FROM [AttributeValue] WHERE [EntityId] = @BlockId AND [AttributeId] = @IsStaticHeightAttributeId | |
SET @TheValue = CASE | |
WHEN @IsStaticHeight = 'True' THEN 'static' | |
WHEN @IsStaticHeight = 'False' THEN 'flexible' | |
ELSE 'static' | |
END | |
IF EXISTS (SELECT 1 FROM [AttributeValue] WHERE [EntityId] = @BlockId AND [AttributeId] = @HeightModeAttributeId) | |
BEGIN | |
UPDATE [AttributeValue] | |
SET [Value] = @TheValue, [IsPersistedValueDirty] = 1 | |
WHERE [EntityId] = @BlockId AND [AttributeId] = @HeightModeAttributeId; | |
END | |
ELSE | |
BEGIN | |
INSERT INTO [AttributeValue] ( | |
[IsSystem], | |
[AttributeId], | |
[EntityId], | |
[Value], | |
[Guid], | |
[IsPersistedValueDirty]) | |
VALUES( | |
1, | |
@HeightModeAttributeId, | |
@BlockId, | |
@TheValue, | |
NEWID(), | |
1) | |
END | |
FETCH NEXT FROM block_cursor INTO @BlockId | |
END | |
CLOSE block_cursor | |
DEALLOCATE block_cursor | |
" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment