Question

I'm looking for the best approach for storing strings in kentico and accessing them programmatically similar to how you would access app.config settings.

Scenario: I wish to create an ITask, which when executed will generate a number of HTML templates. I would allow entry of the text fields via Kentico. The templates are backbone templates.

My initial thought would be to store them in UI Culture and then access them via the task but I'm having some difficulty doing this as it's a scheduled task I don't have access to the HttpContext.

Potentially I should be storing these values in custom settings?

Was it helpful?

Solution

so i found the answer.

// ResHelper
using CMS.GlobalHelper;
using CMS.SiteProvider;

    // Get culture ID from query string
    var uiCultureID = QueryHelper.GetInteger("UIcultureID", 0);

    // Get requested culture
    var ui = UICultureInfoProvider.GetSafeUICulture(uiCultureID);

    var dui = UICultureInfoProvider.GetUICultureInfo(CultureHelper.DefaultUICulture);

    var s = ResHelper.GetString("myculturevalue.test", dui.UICultureCode);

for those interested in the task, take a look here http://devnet.kentico.com/Blogs/Martin-Hejtmanek/June-2010/New-in-5-5-Provide-your-classes-from-App_Code.aspx

thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top