0

使用 Orchard 1.6 我创建了一个表单(用户从前端访问)

此表单包含一个内容部分,因此当它被提交时,它将被存储为一个内容项。

然后,我想从前端以表格格式显示仅此用户提交的先前内容项(因为用户将登录)

作为管理员,我可以从仪表板查看此列表,但是用户只能访问前端。

如何从前端显示内容项列表?

4

1 回答 1

1

I'm pretty sure you have asked this exact question before... And people have said use projections or write your own code to query the content items you need.

So say your content items are notes. And you have attached a NotePart to them. Your NotePart might look like this:

public class NotePartRecord : ContentPartRecord
{
    public virtual string Title { get; set; }

    public virtual string NoteContent { get; set; }

    public virtual UserPartRecord UserPartRecord{ get; set; }
}

The UserPartRecord would be the record of the user who created it. You could then query it like this:

this.services.ContentManager
                .Query<NotePart>()
                .Where<NotePartRecord>(e => e.UserPartRecord.Id == user.Id)
                .List()

where services is IOrchardServices. You could then select the data you want to display or just display the entire content item.

I would recommend looking through Orchards source code, examples of how to do pretty much everything :)

于 2013-08-28T16:30:21.313 回答