Create Module that uses DateTimeField

Topics: Writing modules
Jun 8, 2012 at 5:56 AM

I've just started using Orchard and I am now going through some of the tutorials. I created a Module in code following this example ( )

Now I want to add a DateTimeField to the module. I want this to use the DateTimePicker that can be used when you add a Field using the Orchard Admin Interface.

I cannot find anything on how to do this.

Can anybody help ?

Jun 8, 2012 at 6:30 AM

You can add fields to a type from a migration. Look for examples of that in existing module. For example, Nwazet.Commerce contains an example that adds a media picker field to its products content type.

Jun 9, 2012 at 2:41 PM

thanks.. that was easier then expected..

I now have multiple items in the content-list.

is it possible to create a projection for this and then sort it on the datetimefield ?

Jun 10, 2012 at 5:58 AM

Sure, can't see why not.

Jun 14, 2012 at 8:52 AM

I'm linking orchard more and more..

The project is coming along nice..  again thanks..

another question related to this module:

I've created the projection and sorted the data by datetime.

I now want to route the include the url of the projection-page..

I think this can be done by setting the value of the "Container" property on the common-part of my module.

But I cannot figure out how to do this.

Any ideas ?

Jun 15, 2012 at 4:44 AM

I don't understand what you mean by "route the include the url of the projection page" sorry.

Jun 15, 2012 at 7:16 AM

I will try to give an example.

My projection page will be located at "/project/news"

I want the news items to get an url like "/project/news/something-happened/"

If I can somehow set the Container part of the news item to the projection page, I can use {Content.Container.Path} in the autoroutepart of the news item.

Did this make it clearer ?

Jun 15, 2012 at 7:39 AM

Looks like what you really need is Taxonomies.

Jun 15, 2012 at 8:18 PM

Thats look like something thats going to solve some future problems for me.. thank you..

I've created a taxonomie "product" and added 2 items to it. I've added paths to both the products..

I've added a Taxonomie field to the news item. So the user can select a product.

I now want the path of the select product to be used by the auto-route part.


How can I do this ?


Jun 15, 2012 at 10:52 PM

There are Fields tokens that you can use for that.

Jun 16, 2012 at 5:50 AM

I've found the token..

I'm now using this as my autoroute - pattern: {Content.Fields.News.Product}/{Content.Slug}

News is my module and product is the taxonomy field.

But when the permalink is generated it only shows the "{Content.Slug}" part..

Will try to debug this.

Jun 16, 2012 at 6:08 AM

Just found an issue that sounds like my issue..

voted for this..

I tried looking through the code.. But I am not that familiar with the code yet..