Question

Using Orchard 1.6 I have created a form (accessed from the front end by a user)

This form contains a content part so when it is submitted it will be stored as a content item.

From the front end I would then like to display in a table format the previous content items that ONLY this user has submitted ( as the user will be logged in)

As the admin I can view this list from the dashboard, however the user only has access to the front end.

How can I display a list of content items from the front end?

Was it helpful?

Solution

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top