This project is read-only.

Set the Title automatically

Topics: Writing modules
Dec 19, 2011 at 10:50 AM

I have wrote my own Module with some Textfields.

Is it possible to set the title automatically?

For example i have a field called Date and a field called name, then the title should be look like "Date_Name".

When yes, how can I do that?




Dec 19, 2011 at 1:21 PM

When Orchard 1.4 is released you should be able to do this with the Autoroute feature.

Dec 19, 2011 at 1:47 PM

Thanks :-)

When will Orchard 1.4 be released?

Dec 19, 2011 at 7:16 PM

If you only want to set only the title automatically (and not the slug) this is possible even with the current 1.3 release with the Tokens module. However this might be an overkill as you can do this more directly by hooking into the life cycle of a part (e.g. with a handler) and just setting the title programmatically, although exactly with the RoutePart this is a bit tricky as the slug is generated somewhere from the title (if you only want the title to auto-generate but your content type is not routable, then this is not an issue).

To the second question: about two weeks ago I dreamed (sincerely) that some core dev stated to release 1.4 soon, although it's a bit overdue :-).

Dec 19, 2011 at 7:33 PM

I kind of misread the original post, you're right Autoroute won't actually let you generate a title, it'll only be able to generate a Url that looks like Date_Name. Your best bet is to forget RoutePart or TitlePart and just use an IContentHandler to hook into GetContentItemMetadata and set the display text there.

Piedone: I believe the slated date was "end of December", well there's no reason why not, but Autoroute still needs some work for completion and we're about to hit Christmas ...