Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • andles 44 posts 64 karma points
    Mar 14, 2011 @ 03:09
    andles
    0

    How to query Umbraco.Config from memory

    Hi,

    Looking at the node api I dont see any way to get the XML directly (using C# here, not XSLT). With the Document api I can use myDoc.ToXML(), but when coverting to the faster node based access, I see no Node based equivalent.

    For now, I'm simply loading the Umbraco.config file and querying it directly, but ideally I wouldnt need to load this document as it already exists in memory, right?

    Ok - any advice here would be much appreciated.

     

    Cheers,
    Andles.

  • Sascha Wolter 615 posts 1101 karma points
    Mar 14, 2011 @ 04:55
    Sascha Wolter
    1

    Hi andles,

    the Nodefactory should be the one you are looking for, see http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory. The namespace has changed though, I think it's just umbraco.Nodefactory now. As the wiki entry says it's directly working on the in-memory representation of umbraco.config, so indeed no need to load it manually.

    You might also want to check out LINQ2Umbraco (http://www.farmcode.org/post/2009/02/24/Linq-to-Umbraco.aspx) which also works on umbraco.config.

    Yet another alternative is to use the new Razor implementation for providing dynamic data in your templates, Gareth Evans has just posted a series of blog posts about it's features: http://umbraco.com/follow-us/blog-archive/2011/2/23/umbraco-47-razor-feature-walkthrough-%E2%80%93-part-1

    Hope that helps,

    Sascha

  • andles 44 posts 64 karma points
    Mar 14, 2011 @ 04:59
    andles
    0

    Brilliant! That will work nicely thank you very much...thanks Sascha.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies