Modify SummaryAdmin view

Topics: Writing modules
Dec 13, 2011 at 1:22 AM

Hi

I want to add some information for specific content type in summary admin view on the content list. Right now I've created new view and called it Parts_Category_SummaryAdmin.cshtml and I added this code to Placement.info

<Match ContentType="Category">
    <Match DisplayType="Detail">  
      <Place Parts_Category="Content:1"/>
    </Match>
    <Match DisplayType="SummaryAdmin">
      <Place  Parts_Category_SummaryAdmin="Content:1"/>     
    </Match>
  </Match>

I even chenged Category driver like this:

    protected override DriverResult Display(CategoryPart part, string displayType, dynamic shapeHelper)
        {
            if (displayType == "Detail")
            {
                return  ContentShape("Parts_Category",
                                        () =>
                                        shapeHelper.Parts_Category(
                                            ContentPart: part
                                            ));
            }
            else
            {
               return ContentShape("Parts_Category_SummaryAdmin",
                        () =>
                        shapeHelper.Parts_Category_SummaryAdmin(
                            ContentPart: part
                            ));                
            }
        }

When I click on the view action in the  content list the right page shows up but I want to see that specific page in the content list too. It worked fine in last version of Orchard but it doesn't work after I updated to version 1.3.

 I just want to show the category name in the content list in admin panel.

Thank you in advance for your help.

Dec 20, 2011 at 12:19 AM

Any help?

 

Coordinator
Dec 20, 2011 at 12:31 AM

Did you try to set a breakpoint in the driver to check if it was getting called?

Dec 20, 2011 at 5:47 AM

Yes I've tried that and it's getting called, This code works perfect in Orchard 1.2 but when I updated to 1.3 it doesn't work anymore!

Coordinator
Dec 20, 2011 at 5:49 AM

What if you set a breakpoint in the template itself?

Dec 20, 2011 at 7:12 AM

I've got the Category.SummaryAdmin.cshtml template in parts folder in my module and it's not getting called. What should I do to get it called?

Coordinator
Dec 20, 2011 at 7:14 AM

Any chance it might get overridden somewhere, like in a theme?

Dec 20, 2011 at 7:16 AM

No, It's not overriden in my theme, is there any where else that I should check?

Coordinator
Dec 20, 2011 at 7:18 AM

Well, if your driver is getting called, then the shape is getting created. If it didn't find a template, it would throw. So it must find one. Question is, where. Make a search on all the files in the system called *category*.cshtml?

Dec 20, 2011 at 7:25 AM

I think it uses the defualt SummaryAdmin template. because I debuged the source code and I noticed the model was ContentItem but for other ContentTypes it was different. But I'm not sure at all.

Coordinator
Dec 20, 2011 at 7:29 AM

We really need shape tracing in the admin. Well, maybe you can put a breakpoint in that template then and dig into the shape. In particular alternates.

Dec 20, 2011 at 7:32 AM

Could you please tell me what the default template for SummaryAdmin is and where it is?

Coordinator
Dec 20, 2011 at 7:44 AM

I can't right now, no, sorry. Try doing a search.

Dec 20, 2011 at 7:46 AM

OK, Thanks a lot for you help.

Dec 20, 2011 at 10:08 AM

Try naming the file Parts.Category.SummaryAdmin.cshtml and placing it in your Views folder, instead of the Parts subfolder.

The default template for SummaryAdmin is in Orchard.Core\Contents\Views\Content.SummaryAdmin.cshtml - but you shouldn't normally need to modify that.

Also, having an if statement to check for the display type in your driver isn't the normal way of doing things. Just return both shapes (with return Combined(...)) and then use placement to show/hide the shapes as appropriate for different display types.

Dec 20, 2011 at 1:15 PM
bertrandleroy wrote:

We really need shape tracing in the admin. Well, maybe you can put a breakpoint in that template then and dig into the shape. In particular alternates.

Is this in the works for 1.4 or 1.5?

Coordinator
Dec 20, 2011 at 5:51 PM
No.

Sent from my TI-99/4A

From: corecomps
Sent: 12/20/2011 5:15 AM
To: Bertrand Le Roy
Subject: Re: Modify SummaryAdmin view [orchard:282715]

From: corecomps

bertrandleroy wrote:

We really need shape tracing in the admin. Well, maybe you can put a breakpoint in that template then and dig into the shape. In particular alternates.

Is this in the works for 1.4 or 1.5?

Dec 20, 2011 at 7:11 PM

I've changed category driver like this:

     protected override DriverResult Display(CategoryPart part, string displayType, dynamic shapeHelper)
        {

            return ContentShape("Parts_Category",
                   () => shapeHelper.Parts_Category(
                       ContentPart: part
                       ));
        }  

And My template: Views/Parts/Category.cshtml :

@using MyModule.Extensions
@using Orchard.ContentManagement;
@using MyModule.Models;

@(((CategoryPart)Model.ContentPart).Name)

PlaceInfo:

<Place Parts_Category="Content:2"/>

Now both driver and template is getting called but the default Summary Admin template shows up and I can't see my template in content list on admin panel.

 


Dec 20, 2011 at 9:50 PM

Finaly I've fixed it.

I debuged the default summary admin page and I found altarnative template's name so I created it (Content__Category.cshtml), then I noticed that I didn't have ContentPart object that I passed through the driver, so I changed my template code to this:

@using Orchard.Utility.Extensions;
@using Orchard.ContentManagement;
@using Netsuite.Models;
@using System.Data.Linq;
@{   
    ContentItem contentItem = Model.ContentItem;
    var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
    }
@(contentItem.Parts.OfType<CategoryPart>().First().Name)
    <div class="related">
        @Display(Model.Actions)
        @Html.ItemEditLink(T("Edit").Text, contentItem) @T(" | ")
        @Html.Link(T("Delete").Text, Url.Action("Remove", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
    </div>

I don't know if it is a best solution but it works now.

Thanks a lot for all your help.