Customizing orchard theme parts
- by madcapnmckay
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