Site labels and other resource strings are something we can manage in Tridion and the SDL Tridion Reference Implementation (STRI) also allows us to manage these key/value pairs in 2 ways. The sample website uses a dedicated Schema for the resources and hardcodes fieldname / fieldvalue in the Schema. The other way is to create a classic config Schema with a multi-value embedded key/value pair Schema.
Updating the existing labels
In the CMS you can find the example resource strings in the Component located at ‘\100 Master\Building Blocks\Settings\Core\Site Manager’. To add a new resouce string, we should edit the Schema and add an additional field to the Schema.
How do we use the existing resource strings in the MVC app?
The Place HTML View has a good example: ‘…\tri-master\web-application\Site\Areas\Core\Views\Entity\Place.cshtml’
@Html.Resource("core.teleponeCaptionText")
Publishing the Resource Strings
And after we change the value of a setting or resource string we need to publish the Page ‘\400 Exmaple Site\Home\_System\Publish Settings’.
The Resource string Component is linked to our ‘Core’ settings Component here: ‘\100 Master\Building Blocks\Modules\Core\Admin\Core’
Creating a new Label set
Creating a new label set is quite easy and also already documented here:
However, for me I wanted to add this to the existing STRI demo site, and that was not 100% clear. Here is how I did it:
- Create a Folder ‘Building Blocks/Settings/MySite/Site Manager’
- Create a Component using the ‘General Configuration’ Schema. The ‘Configuration Name’ field is not used.
- Link the new Labels Component from the step above to ‘\100 Master\Building Blocks\Modules\Core\Admin\Core’ in the Resources field.
- Publish the ‘Publish Settings’ page here ‘\100 Master\Home\_System’
- Display the label in a View, for example the Article view here ‘…\tri-master\web-application\site\areas\core\views\entity\article.cshtml’
@Html.Resource("core.contactUs")
The ‘core’ here refers to the ‘Module name’ of the ‘Module Configuration’ Component at ‘\100 Master\Building Blocks\Modules\Core\Admin’ and the Module name is taken from the Path of the Component. It is also the Module in the Publish Settings Page.
The ‘contactUs’ is the Key of our label.
6. Refresh the Web app going to the ‘http://localhost:59860/admin/refresh’ and see the new Label