Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
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"
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:
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted