Display attribute ignored for group definitions for pages or blocks

Vote:
 

I created a custom group name that I wanted some of my page types to be listed under when creating new instances. This seems to work great when the name of the group is only a single word, but friendly names with spaces are ignored. Here is an example of my group definition:

        [GroupDefinitions]
        public static class ContentGroupNames
        {
            [Display(Name = "Custom Pages", Order = 70)]
            public const string CustomPages = "CustomPages";
        }

At run time the name of the group shows the constant name "CustomPages", rather than the friendly name with the space from the Display attribute. These work just fine for tabs within content, but not for page or block group names. 

#204598
Jun 10, 2019 17:55
Vote:
 

Hi Jason,

It's using the string value, so you could update it to:

[GroupDefinitions]
public static class ContentGroupNames
{
    [Display(Order = 70)]
    public const string CustomPages = "Custom Pages";
}

and it will work.

Or, if you need localization, then add the following to the language XMLs:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<languages>
    <language name="English" id="en">
        <groups>
            <custompages>Custom Pages</custompages>
        </groups>
    </language>
</languages>
#204602
Jun 10, 2019 19:36
Vote:
 

So am I forced to use the constant value as the display value? Is the Display attribute ignored all together?

#204605
Jun 10, 2019 22:06
Vote:
 

Hi again,

Noyou're not actually forced to use the string value, ideally you'd use the XML approach. That's the Episerver reccomendation as per the documentation (see 'Localizing headers'):

https://world.episerver.com/documentation/developer-guides/CMS/globalization/localizing-the-user-interface

After a quick peek in the code I can't see that it ever uses the DisplayAttribute Name when using group definitions, but maybe I'm missing something.

#204606
Jun 10, 2019 22:41
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.