Rock.Model.BlockService.GetByLayoutAndZone C# (CSharp) Method

GetByLayoutAndZone() public method

Returns an enumerable collection of Blocks that are implemented in a specific zone on a Site Layout template.
public GetByLayoutAndZone ( int layoutId, string zone ) : IQueryable
layoutId int An representing the Id of the that the block belongs to.
zone string A representing the name of the Zone to search by.
return IQueryable
        public IQueryable<Block> GetByLayoutAndZone( int layoutId, string zone )
        {
            return Queryable()
                .Where( t =>
                    t.LayoutId == layoutId &&
                    string.Compare(t.Zone, zone ) == 0)
                .OrderBy( t => t.Order );
        }

Usage Example

Example #1
0
        /// <summary>
        /// Binds the grids.
        /// </summary>
        private void BindGrids()
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );

                gLayoutBlocks.DataSource = blockService.GetByLayoutAndZone( _Page.LayoutId, _ZoneName )
                    .Select( b => new
                    {
                        b.Id,
                        b.Name,
                        BlockTypeName = b.BlockType.Name,
                        BlockTypePath = b.BlockType.Path
                    } )
                    .ToList();
                gLayoutBlocks.DataBind();

                gPageBlocks.DataSource = blockService.GetByPageAndZone( _Page.Id, _ZoneName )
                .Select( b => new
                {
                    b.Id,
                    b.Name,
                    BlockTypeName = b.BlockType.Name,
                    BlockTypePath = b.BlockType.Path
                } )
                .ToList();
                gPageBlocks.DataBind();
            }
        }
All Usage Examples Of Rock.Model.BlockService::GetByLayoutAndZone