Introduction to Sitecore 7.2 MVC with TDS and Glassmapper Tutorial with Anindita Bhattacharya
Sitecore User Group Bangalore - Kick Off Session @ Verndale Bangalore (March 28 2015)
3. Sitecore is one of the leading enterprise-level content management systems
built on ASP.NET, enabling web content editors and marketers to have full
control over all aspects of their website from social integration and blog posts
to advanced personalisation, e-commerce and more.
SITECORE
COPYRIGHT 20153
4. • Powerful development platform, based on the latest Microsoft technology.
• Pipeline based architecture that is open and extensible
• Page Designer – content on the fly
• Strong multisite support
• Multi language flexibility
• Advanced security
• Powerful workflow
INTRODUCTION TO SITECORE
COPYRIGHT 20154
6. • True separation of concerns – Do you see the light?
• View Renderings vs Controller Renderings
• Always do a datasource null check in the beginning of the view
• Display placeholder text in the event of no datasource in pageeditor
mode
TIPS ON SITECORE MVC USAGE
COPYRIGHT 20156
7. • Yes we don’t like empty html tags – but we need to ensure they show up
in page editor mode with the item field in question!
• Add comments to demark the start and end of renderings – it will make
your life simpler!
• Grouping controllers rendering actions – to do or not to do?
• Accessing non-rendering actions (ajax?)
/api/sitecore/samplecontroller/sampleaction?sampleparam=abc
• Post actions – Html.Post vs Ajax.Post
TIPS ON SITECORE MVC USAGE
COPYRIGHT 20157
8. Team Development for Sitecore (TDS) gives you the ability to keep track of
all the Sitecore items in your project, by bringing them into a Microsoft
compliant Source Code Control system.
Key concept: Serialization of Sitecore (Database) Items into Files
TDS
COPYRIGHT 20158
10. In Short: Advangates of TDS Version control for Sitecore Items!
Extensive TDS documentation: http://hedgehogdevelopment.github.io/tds/
TDS
COPYRIGHT 201510
11. • Complete accountability and audit trail.
• All of your Sitecore items and code are stored in a single repository.
• Developers can work remotely or disconnected from the network and then sync and
merge changes at a later date to the source code control system.
• You can easily compare versions of items and code.
• You can rollback to prior versions if there is a problem.
• You can easily merge changes.
• Branching and other advanced source code management techniques can be leveraged.
• Continuous integration and automated builds.
TDS
COPYRIGHT 201511
13. • TDS sync vs TDS deploy
• Avoid conflicts – save your time
Get latest before you attempt check in to avoid bad merge (TFS)
• Use the TDS build
Separation of working vs deployment directory – additional façade.
Keep the hefty sitecore folder outside of your source control!
• Keep your project paths short, and keep an eye on your sitecore item
name lengths as well
256 characters file path size limit
TIPS ON TDS USAGE
COPYRIGHT 201513
14. • Sync in only necessary items
- Excessive content, fairly constant sitecore items which come in with a fresh install – good
examples of items you wouldn’t need in your TDS project
- Use NoChildSynchronization where needed.
• Duplicate item names in same section not supported
TIPS ON TDS USAGE
COPYRIGHT 201514
15. Unicorn (for automatic serialization of your changes to Sitecore items)
Courier (for package generation based on serialized items)
Sitecore Ship (for automated deployment of Sitecore packages)
Combination of the above open source tools will enable you achieve the
same results!
Credit: http://stackoverflow.com/users/181142/ruud-van-falier
ALTERNATIVE SOLUTION
COPYRIGHT 201515
17. Glass is home to the #1 ORM for Sitecore and Umbraco. Glass.Mapper is the
easiest way to map data from your Sitecore or Umbraco solution to your
code. http://www.glass.lu/
Extensive tutorials available at: http://www.glass.lu/en/Mapper/Sc/Tutorials
GLASS.MAPPER
COPYRIGHT 201517
20. • Use Glass generated models wherever you possibly can
• Always add null checks before rendering item fields.
• Your glassmapper model and version control (TFS) merge issues
Solution - Delete model - regenerate
• Keep your data clean – avoid mapping exceptions!
Ensure your Broken Links Report is clean
TIPS ON GLASS.MAPPER USAGE
COPYRIGHT 201520
21. • Keep page editor support in mind at all times!
• Override glass html helpers in GlassView as and when needed based on
your requirements
Eg. Resized images in normal mode
• Keep an eye on the size of your model file. Split your TDS projects if
necessary
Only generate code for items that you NEED to use in your code
Remember – child items inherit the code generation property from parent!
TIPS ON GLASS.MAPPER USAGE
COPYRIGHT 201521
22. • Update the header tt file if need be.
Eg. System templates, template Id
• ‘Error generating code’ issue – one formula – Delete model.cs,
regenerate!
• When to create Custom Models?
TIPS ON GLASS.MAPPER USAGE
COPYRIGHT 201522
24. • May / June 2015
• Front end coding workflow for Sitecore Sites
• Slot open for ideas / requests!?
Mail us at: sitecoreusergroup.bangalore@gmail.com
Join us
https://www.linkedin.com/groups?gid=6700964
www.meetup.com/sug-bangalore
Follow us on Twitter @sugblr
FOR THE NEXT SUG BANGALORE SESSION
COPYRIGHT 201524
Editor's Notes
Participation from everyone
Single out the best ways to do things – the way we do it might not be the best – hence the want for participation!
Knowledge share
Invite ideas for presentations
Not just back end – FE / User Experience / Digital Marketing – any dept
Once in 2 months
Show build deploy
Talk of sync vs deploy
Sync both ways
Child sync option
itempaths.tt – freedom from guids!
Page editor and glass view
Inheritance in glass classes