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
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the GridReorder event of the gLayoutBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gLayoutBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );
                var blocks = blockService.GetByLayoutAndZone( _Page.LayoutId, _ZoneName ).ToList();
                blockService.Reorder( blocks, e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            Rock.Web.Cache.PageCache.FlushLayoutBlocks( _Page.LayoutId );
            PageUpdated = true;

            BindGrids();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the GridReorder event of the gLayoutBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gLayoutBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );
            var blocks = blockService.GetByLayoutAndZone( page.LayoutId, zoneName ).ToList();
            blockService.Reorder( blocks, e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();

            Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId );
            BindGrids();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Binds the layout grid.
        /// </summary>
        private void BindLayoutGrid()
        {
            BlockService blockService = new BlockService( new RockContext() );
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            gLayoutBlocks.DataSource = blockService.GetByLayoutAndZone( page.LayoutId, zoneName ).ToList();
            gLayoutBlocks.DataBind();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the GridReorder event of the gLayoutBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gLayoutBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            BlockService blockService = new BlockService();
            int pageId = PageParameter( "EditPage" ).AsInteger() ?? 0;
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            blockService.Reorder( blockService.GetByLayoutAndZone( page.LayoutId, zoneName ).ToList(), e.OldIndex, e.NewIndex, CurrentPersonId );

            BindGrids();
        }