Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Dan 61 posts 185 karma points
    Dec 01, 2020 @ 07:47

    language variation on layout description

    Hi Perplex If I want the use dictionary items in description how would I do that. I tried to inject the umbraco helper but ended with Umbraco Boot Failed error.

     new ContentBlockLayout
                            Id = new Guid("22222222-2222-2222-2222-222222222222"),
                            Name = "Red",
                            Description = UmbracoHelper.GetDictionary("test"),
                            PreviewImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAATSURBVAiZYzzDwPCfAQqYGJAAACokAc/b6i7NAAAAAElFTkSuQmCC",
                            ViewPath = "~/Views/Partials/ExampleBlock/Red.cshtml"
  • Daniël Knippers 152 posts 1115 karma points MVP 2x c-trib
    Dec 14, 2020 @ 08:52
    Daniƫl Knippers

    Hi Dan,

    Hmm, I don't use the dictionary often but this returns a different value based on the language of the current Umbraco user I believe? The code you posted is executed on boot already and has no idea about the context of the request of the backoffice. This will indeed not work out of the box.

    However, you can implement your own IContentBlockDefinitionRepository and in the GetAll() method you can probably use the dictionary at runtime. So perhaps just set Description to "test" in your code on startup, and in your own repository implementation you fetch the correct dictionary entry and write that to the Description field. Basically, in your own implementation of the repository you have complete freedom to execute whatever code you want, so I'm sure there are ways to make it work that way.

    You register your own repository with this code in a composer: composition.RegisterUnique<IContentBlockDefinitionRepository, MyDefinitionRepository>();

Please Sign in or register to post replies

Write your reply to: