This project is read-only.

Contents shape for listing

Topics: Writing modules
Apr 21, 2012 at 3:44 PM

I'm still trying to understand the world of clay and shapes.

I've started with creation of action to show the list of my custom items, and ended up with the following code:


        public dynamic ListContent(string type, PagerParameters pagerParameters)
            Pager pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters);

            var query = Services.ContentManager.Query().ForType(type).ForVersion(VersionOptions.Latest);

            var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
            var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();

            var list = Shape.List();
            list.AddRange(pageOfContentItems.Select<ContentItem, object>(ci => Services.ContentManager.BuildDisplay(ci, "SimpleAdmin")));

            var viewModel = Shape.ViewModel();
            return viewModel

I've also added a handler for ContentPart in my module, which return Parts_Contents_SimpleAdmin shape and registered it in placement info.

The problem is that I'm unable to hide/overrride the Parts.Contents.Publish.SummaryAdmin.cshtml result, therefore i still see the view and unpublish buttons.


I saw the similar problem here is there are better way than hiding it using JavaScript?

Apr 21, 2012 at 3:53 PM

Sorry, the method above does work. There "Parts.Contents.Publish.SummaryAdmin" has been set in child module

May 22, 2013 at 11:21 AM
Can you explain how actually did you managed to solve this, as now I'm facing similar problem?