开发者

Is it possible to create an alternative for List in Orchard?

I just want to customi开发者_StackOverflowze List view.

is it possible? I think yes. How?

How to name alternative for List of Content types, let say, "Question"


Sure. As the question is a little vague about context, I'll make assumptions. I'll assume that you have a controller action building the list (similar to what the blog is doing). From the action, you are usually building a list shape with code looking something like this:

var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var things = _someServiceClass.GetThings(something)
    .Skip(pager.GetStartIndex()).Take(pager.PageSize))
    .Select(p => Shape.Thing_Summary(
        Thing: p,
        SomethingElseThatIsRelevantToTheTemplate: foo));

Shape list = Shape.List(Pager: pager);
list.AddRange(things);
list.Metadata.Alternates.Add("list_things");

return new ShapeResult(this, list);

See that line near the end? It's adding the alternate, so that you can build a specific template for that particular list by creating a file named list.things.cshtml in the views folder of your theme.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜