Inheriting UmbracoHelper or CultureDictionaryFacto...
# help-with-umbraco
o
Hey everyone, I've a scenario where I have a partial view which requires to access a Dictionary item, it's going to be a multilingual site. The issue I have is the partial doesn't use
UmbracoPageView
and so doesn't know what
Umbraco.GetDictionaryValue
is. It's just has a
BlockListItem<>
model assigned to it. One option that was suggested to me was to inject
@inject Umbraco.Cms.Web.Common.UmbracoHelper Umbraco
but then I was told this is potentially unsafe. The other suggestion was to inject
@inject ICultureDictionaryFactory _cultureDictionaryFactory
which then gives me access to the dictionary via
Copy code
var dictionary = _cultureDictionaryFactory.CreateDictionary();
...
@dictionary[DictionaryKey.InteractionsReadMore].IfNullOrWhiteSpace("Read more")
Is one option better than the other or is there a third option that I'm not aware of which is even better / safer. This is an Umbraco 13 site.
Just as a follow up - sometimes keeping it simple is the best option 😄 I've just wrapped my BlockListItem model with UmbracoViewPage -
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<BlockListItem<CallToActionGridCard>>
I would be interested to hear peoples thoughts on this approach.
7 Views