RegisterBlockTypes() public static method

Registers any block types that are not currently registered in Rock.
public static RegisterBlockTypes ( string physWebAppPath, System page, bool refreshAll = false ) : void
physWebAppPath string A containing the physical path to Rock on the server.
page System The .
refreshAll bool if set to true will refresh name, category, and description for all block types (not just the new ones)
return void
Beispiel #1
0
        /// <summary>
        /// Loads the block types.
        /// </summary>
        private void LoadBlockTypes()
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                Rock.Model.BlockTypeService blockTypeService = new Rock.Model.BlockTypeService();

                // Add any unregistered blocks
                blockTypeService.RegisterBlockTypes(Request.MapPath("~"), Page, CurrentPersonId);

                ddlBlockType.DataSource     = blockTypeService.Queryable().OrderBy(b => b.Name).ToList();
                ddlBlockType.DataTextField  = "Name";
                ddlBlockType.DataValueField = "Id";
                ddlBlockType.DataBind();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the block types.
        /// </summary>
        private void LoadBlockTypes()
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                Rock.Model.BlockTypeService blockTypeService = new Rock.Model.BlockTypeService();

                // Add any unregistered blocks
                blockTypeService.RegisterBlockTypes(Request.MapPath("~"), Page, CurrentPersonId);

                // Load the block types
                var blockTypes = blockTypeService.Queryable()
                                 .Select(b => new { b.Id, b.Name, b.Category, b.Description })
                                 .ToList();

                ddlBlockType.Items.Clear();

                // Add the categorized block types
                foreach (var blockType in blockTypes
                         .Where(b => b.Category != "")
                         .OrderBy(b => b.Category)
                         .ThenBy(b => b.Name))
                {
                    var li = new ListItem(blockType.Name, blockType.Id.ToString());
                    li.Attributes.Add("optiongroup", blockType.Category);
                    li.Attributes.Add("title", blockType.Description);
                    ddlBlockType.Items.Add(li);
                }

                // Add the uncategorized block types
                foreach (var blockType in blockTypes
                         .Where(b => b.Category == null || b.Category == "")
                         .OrderBy(b => b.Name))
                {
                    var li = new ListItem(blockType.Name, blockType.Id.ToString());
                    li.Attributes.Add("optiongroup", "Other (not categorized)");
                    li.Attributes.Add("title", blockType.Description);
                    ddlBlockType.Items.Add(li);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Loads the block types.
        /// </summary>
        private void LoadBlockTypes()
        {
            using ( new Rock.Data.UnitOfWorkScope() )
            {
                Rock.Model.BlockTypeService blockTypeService = new Rock.Model.BlockTypeService();

                // Add any unregistered blocks
                blockTypeService.RegisterBlockTypes( Request.MapPath( "~" ), Page, CurrentPersonId );

                // Load the block types
                var blockTypes = blockTypeService.Queryable()
                    .Select( b => new { b.Id, b.Name, b.Category, b.Description } )
                    .ToList();

                ddlBlockType.Items.Clear();

                // Add the categorized block types
                foreach ( var blockType in blockTypes
                    .Where( b => b.Category != "" )
                    .OrderBy( b => b.Category )
                    .ThenBy( b => b.Name ) )
                {
                    var li = new ListItem( blockType.Name, blockType.Id.ToString() );
                    li.Attributes.Add( "optiongroup", blockType.Category );
                    li.Attributes.Add( "title", blockType.Description );
                    ddlBlockType.Items.Add( li );
                }

                // Add the uncategorized block types
                foreach ( var blockType in blockTypes
                    .Where( b => b.Category == null || b.Category == "" )
                    .OrderBy( b => b.Name ) )
                {
                    var li = new ListItem( blockType.Name, blockType.Id.ToString() );
                    li.Attributes.Add( "optiongroup", "Other (not categorized)" );
                    li.Attributes.Add( "title", blockType.Description );
                    ddlBlockType.Items.Add( li );
                }
            }
        }