This project is read-only.

Orchard tokens, can they be used in title and content parts?

Topics: Core, General
Aug 27, 2012 at 1:25 PM
Edited Aug 27, 2012 at 1:30 PM


I really like the Orchard tokens and I'd like to use them, but it seems to me that I can only use them in very limited places. The only places that I know of so far where I can use them out of the box are when adding an Autoroute Part to a content type and when adding a custom lay-out to a Query.

But I'd like to be able to use the tokens anywhere and everywhere. For example: I want to create a menu item on my site with the username of the logged in user and when they click on it, they go to their profile page. The default Orchard theme has that in the footer, but I can't seem to find where it comes from. But even if I did, I want to be able to add a menu item like that via the admin panel instead of hardcoded in the theme.

Besides that it could also be very usefull if you would be able to use tokens in the TitlePart, ContentPart, etc.

So my suggestion is to make it possible to use Orchard Tokens in any text-field possible, if this is not already the case. If that already is possible, please tell me how, because simply adding "{User.Name}" to a title does not work. I have found a Token Title module, but I can't use that one since the menu item type does not use the title part for the title of the menu item, it uses something else.

Aug 27, 2012 at 10:25 PM

Although I've never measured how much, but tokenizing does adds some overhead, so tokenizing everything might not always be a good idea.

That footer you've mentioned comes from the User.cshtml shape, you can override it to make it look different or override the Layout.cshtml from SafeMode what adds it to the footer at ln 8.

On how everything could be tokenized: not an easy question and I think should be looked at on a case-by case basis. The problem is that if you would like to make standard fields tokenized you should tokenize them somewhere before displaying (i.e. replace them). I'm not sure how this could be done, because you can't simply set a part's property to the tokenized value (would overwrite it), so maybe the only way to do it is from either a shape (by overriding existing ones) or by adding new drivers to the parts with new display shapes that get the tokenized values.

Yeah that Token Title module is awesome BTW ;-).

Aug 28, 2012 at 8:38 AM

Hm yes I can understand that it causes some overhead and that it might be hard to make, didn't really think about that to be honest. But I hope it can be at least taken into consideration by the Orchard team, because I think it would be a really usefull option.

Anyhow, thanks for telling me about the User.cshtml, I will probably use that for now then. 

Yes the Token Title module is nice, I see that you made it hehe :P