0
votes

I am new to orchardCMS and using Orchard v.1.8.1.0. I have a custom content type named "Event" and I am creating custom form which will enable anonymous users to register for any particular event.

I am not able to show list of events in the custom form. I tried using content picker field but I am getting access denied even allowing anonymous user role to view all events.

Can anyone guide me in the right direction? I will be very thankful to you.

Thanks

1
You need to specify more about your particular setup. There are a lot of ways in which you might be implementing the above solution. Are you creating a module? What do you mean by 'custom form'? Are you using a (3d party) module for this, or are you implementing a custom form in your own module?Ropstah

1 Answers

0
votes

Regarding security, you can specify which roles have access to specific contenttypes in the admin under "Users".

Regarding loading of data, you can always create a service class to load the data (implement IDependency so you can inject it in other classes like Controllers or Handlers).

public class EventService : IEventService {
    private IContentManager _contentManager;
    public EventService(IContentManager contentManager) {
        _contentManager = contentManager;
    }

    public IEnumerable<IContent> GetEvents() {
        return _contentManager.Query("Event").List();
    }
}

public interface IEventService : IDependency {
    IEnumerable<IContent> GetEvents();
}

Now you're able to load the data. How are you going to use or display it? Knowing this is essential in finding a solution as to where you want to load the data. This could be in a Controller or somewhere in a ContentPartDriver implementation, the former requires 'manual' displaying/storing of data, the latter requires the creation of a contentpart, driver, handler and placement. But proper implementation handles displaying and storing of data.