autoroute custom pattern using field value?

Topics: Customizing Orchard
Mar 6, 2012 at 7:52 AM

I have a custom content type with a Date Time field that allows date only named MeetingDate

I'd like to have a custom route on it that uses the MeetingDate field to display routes like this: 

/Meetings/12/02/2012

I'm thinking something similar to this:

{MeetingDate.Date.Format:MM}/
{MeetingDate.Date.Format:dd}/{MeetingDate.Date.Format:yyyy}

How do I do this with a custom autoroute pattern?



        
    
Coordinator
Mar 6, 2012 at 8:16 AM

From the top of my head that would be something like {ContentItem.Fields.YourContentType.MeetingDate...}

Mar 6, 2012 at 8:43 AM

Bertrand, thanks for the quick reply. That did not work and a few other variations didn't work. Any guidance on how I can figure this out?

Guessing, looking through the source code, shape tracing, documentation?

Coordinator
Mar 6, 2012 at 7:20 PM

{Content.Fields.YourContentType.YourField} ... but I am not sure there is a token for DateTimeField which would return the Date by default.

Let me create a work item for this.

Coordinator
Mar 6, 2012 at 7:21 PM

http://orchard.codeplex.com/workitem/18534

Mar 6, 2012 at 7:23 PM

Thanks for digging in sebastianros!

Dec 7, 2012 at 3:17 PM

I've tried doing this with a custom field. I'm using 1.6.

/events/{Content.Fields.EventCalendar.EventDateandTime.Format:yyyy}/{Content.Fields.EventCalendar.EventName}

Shows up as

events//ABC12333

When I use

/events/{Content.Fields.EventCalendar.EventDateandTime}/{Content.Fields.EventCalendar.EventName}

It shows the long version of 

/events/2013-01-01T05:00:00.0000000Z/ABC12333

Coordinator
Dec 8, 2012 at 11:14 PM

This should work. Looks like a regression. Please file a bug.

Dec 17, 2012 at 8:58 PM

Needed to use:

/events/{Content.Fields.EventCalendar.EventDateandTime.DateTime.Format:yyyy}

Thanks!