Customizing orchard theme parts

Posted by madcapnmckay on Stack Overflow See other posts from Stack Overflow or by madcapnmckay
Published on 2011-02-05T15:22:17Z Indexed on 2011/02/05 15:25 UTC
Read the original article Hit count: 312

Filed under:
|
|

Hi,

I am trying to write a custom theme for orchard and am not having much success so far. I have read Bertrand Le Roy's article on part alternates but I can't seem to get it to work.

I am displaying a list of recent blog posts on the front page, pretty standard. I wish to change the markup produced by the meta data part i.e the time format.

I have written a IShapeTableProvider to create blog specific alternates for the metadata summary part.

public class MetaDataShapeProvider : IShapeTableProvider
{
    private readonly IWorkContextAccessor workContextAccessor;

    public MetaDataShapeProvider(IWorkContextAccessor workContextAccessor)
    {
        this.workContextAccessor = workContextAccessor;
    }

    public void Discover(ShapeTableBuilder builder)
    {
        builder
          .Describe("Parts_Common_Metadata_Summary")
          .OnDisplaying(displaying =>
          {
              ContentItem contentItem = displaying.Shape.ContentItem;
              if (contentItem != null)
                displaying.ShapeMetadata.Alternates.Add("Metadata__" + contentItem.ContentType);
          });
    }
}

This is being caught correctly but the contentItem is null. Should I just create an alternate with a fixed name like "Metadata-BlogPost" and use that, to make this general purpose it should really be a dynamic name so I can use another alternate template elsewhere.

Thanks,

Ian

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc