Friday, September 29, 2017

TDS code generation for content items

Code generation of templates works great with glass mapper and TDS in your Sitecore project, however there are times where content items may need to have classes generated. An example would be system pages or settings, which are serialized/deployed and in which item IDs may be required in other areas of code.

Instead of manually declaring these IDs in a static class like the old days, TDS can generate these classes which makes it a bit more dynamic. This makes use of the transformation file:

And is as simple as editing the properties on the path where you want content serialized - in this case the content item.

Notice that Code Generation Template has been set for this content item. Now when the coder generation is re-run this content item and it's children all have classes available:

No comments:

Post a Comment