Managing common micro content

Topics: Feature requests, General
Jul 31, 2011 at 7:14 AM

Is it already possible to manage and create common used text fields like "Read more".

offcource it can be a field which is part of a content type but the problem is that if you have for example 10000 pages and you want to change the text you have to edit them all. An other option is to create widgets but that's very hard to manage if you have many text fields in combination with multiple layouts and languages. In other CMS systems i've seen they used separate solution (managable within the backend) for this called Dictionary Items so something similar as Resources in ASP.net but managable in the CMS backend.

Jul 31, 2011 at 9:55 AM

Orchard suports two kinds of localization: content localization and application localization. Please, reference this article for more information: http://orchardproject.net/docs/Creating-global-ready-applications.ashx.

So, if you need to define a reusable translation for your content, you have to define a template for it and use T() method for declaring localizable strings. Take a look at the Body part summary template (\Core\Common\Views\Parts.Common.Body.Summary.cshtml):

 

@{ 
    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    string bodyHtml = Model.Html.ToString();
    var body = new HtmlString(Html.Excerpt(bodyHtml, 200).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>")); 
}
<p>@body @Html.ItemDisplayLink(T("more").ToString(), contentItem)</p>

 

Here you can see that template makes use of T() method for rendering localizable "more" string.

Jul 31, 2011 at 11:02 AM

Ok thanks. that's partially a solution. but is it true that these translations are in fact "hardcoded" in the po files and are not managable within the backend?

Jul 31, 2011 at 11:36 AM

Unfortunately there is nothing exposed to the backend. I know that they have an online translation tool for contributors. I usually use command-line utils provided by Translation Manager module for working with .po files.