1

I've a template with sections below:

Section A
   Title
   Name
Section B
   Title 
   Name

Looks good on Sitecore. However when TDS Glass mapper generates the code, it generates Title and name twice.

Wondering if it's possible to add the section name before each field when glass mapper generates the code.

If you ask me why, it's to avoid 248 character length error for windows file system for TDS items as I had done this as work around.

Section A
       Section A Title
       Section A Name
Section B
       Section B Title 
       Section B Name

Any help will be awesome.

Thanks.

Jason Horne
  • 595
  • 3
  • 12
Nil Pun
  • 17,035
  • 39
  • 172
  • 294

1 Answers1

3

It is generally not good practice to have Fields with the same name defined multiple times in the same template. Although Sitecore will allow you to do that and will be able to identify the fields separately by the Field ID - Most code uses field names or generated code to do that. When referencing the fields by name, it will fail.

You have 2 options.

Option 1 It is better practice to either prefix the names or come up with a unique naming convention, as you have done in your example

Option 2

As an alternative you could modify the T4 template to prefix the field names when generating the code, with the section name. This would allow the code to compile. But depending on how the fields are being mapped by Glass (normally this is by field name, not ID) - it will still cause issues as Sitecore will not know which field to use.

I would go with Option 1

Richard Seal
  • 4,248
  • 14
  • 29