Rendering table on front end using BuildDisplay

Topics: Writing modules
Jul 3, 2012 at 7:58 PM

I'm having a small problem trying to understand how to get this to display properly. I'm retrieving some Content Items from the database and would like to render them in a nice table display on the front-end (not admin).

To help with this, I'm using the Orchard Custom Shapes module (or at least I integrated it into my module).

Everything works well, except that the properties for my Content Items are not displaying inside the table that is being rendered. I believe this may be because I'm rendering the entire Content Item. I'm just not sure how to render them differently so that the properties end up in the table. I believe my issue is in the Controller code:

        public ActionResult List() {
            var requesttypes = _requesttypeService.Get().Select(b => _orchardServices.ContentManager.BuildDisplay(b, "List"));

            var list = Shape.Table();
            list.ItemHeaders = new List<string>(){"Name"};

            dynamic shape = Shape.Table()

            return View((object)shape);

Here is the View (List.cshtml)

<h4>@T("Request Types")</h4>

 and the Shape (Parts.RequestType.cshtml)

@using InfoSource.Requests.Models
    var requesttypePart = (RequestTypePart)Model.ContentPart;

The HTML output is surrounding each @requesttypePart.Name in an <article> tag and below the list of all of them, the <table> code shows up from the custom shape.

Any clues on what I need to do to get the @requesttypePart.Name to show up inside the table instead of before it? I know I'm missing something really obvious here.

Here is the Driver code in case that helps

        protected override DriverResult Display(RequestTypePart part, string displayType, dynamic shapeHelper) {
            return Combined(ContentShape("Parts_RequestType",
                () => shapeHelper.Parts_RequestType(ContentPart: part)));
Thanks for any help you can provide.

Jul 3, 2012 at 8:03 PM

What is Orchard Custom Shapes module ?

Jul 3, 2012 at 8:24 PM
Edited Jul 3, 2012 at 8:24 PM

Basically just a custom shape

Jul 3, 2012 at 8:34 PM

AH! I think I got it. All I had to do in the View was add a <td> tag around