How to get Site root using Glass Mapper

339 views
Skip to first unread message

Sar

unread,
Jun 20, 2014, 3:02:14 PM6/20/14
to glass...@googlegroups.com
HI,

I am using Sitecore 7.1 with glass mapper. I created a website root template under the \sitecore\content and created a home node under site root template. 

My content tree structure is Sitecore --> Content --> Website root --> Home

I am trying to get site root item to read site specific settings but I am not able to do it.



Does any one have any idea about this?  

Thanks,
Sar.

amar...@avantia-inc.com

unread,
Oct 22, 2015, 4:15:31 PM10/22/15
to Glass.Mapper
It's been a while since this was posted, but did you ever find a solution?  I'm having this same problem.

Michael Edwards

unread,
Oct 22, 2015, 4:47:16 PM10/22/15
to amar...@avantia-inc.com, Glass.Mapper
Hi

Sorry we didn't see this. You have two options the ISitecoreContext provides a GetHomeItem method which uses the settings in the site node of the web.config. This is ok but will break in the page editor on multi-site solutions, this isn't a Glass bug but is to do with the way that Sitecore resolves sites.

A better alternative is to use an ancestor query using Sitecore XPath, you can do this via one of the query methods on the ISitecoreService or as a property on a model using the Sitecore Query mapper.

If it helps we can offer consultancy to show you how to achieve this. We also cover this topic on our training courses.

Thanks

Mike



--
You received this message because you are subscribed to the Google Groups "Glass.Mapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glassmapper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages