Copied to clipboard

Flag this post as spam?

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


  • Johan 3 posts 53 karma points
    Feb 28, 2015 @ 15:43
    Johan
    0

    querying node names case-insensitive?

    I like the feature that you are able to query the umbraco.config xml file found in App_Data folder but I would like to do it case-insensitive and I havent solved that yet.

    foreach(var item in Umbraco.TypedContent(1320).Children.Where("Name = \""+nodename+"\"")){
    // Get One node here
    }

     I have a node with name SharePoint in my umbraco instance and that node is store inside umbraco.config as:

     

          
          <AffarssystemBuzzWord id="1345" parentID="1320" level="3" creatorID="0" sortOrder="59" createDate="2013-11-12T20:36:09" updateDate="2015-02-28T12:35:07" nodeName="SharePoint" urlName="SharePoint" path="-1,3263,1320,1345" isDoc="" nodeType="1319" creatorName="[email protected]" writerName="[email protected]" writerID="0" template="1323" nodeTypeAlias="AffarssystemBuzzWord">
            <umbracoNaviHide>0</umbracoNaviHide>
            <sortOrderMain>1</sortOrderMain>
            <buzzWord>SharePoint</buzzWord>
            <description><![CDATA[<p>Är Microsofts plattform för att skapa intranät som jobbar och fungerar bra tillsammans med övriga affärssystemet.</p>]]></description>
          </AffarssystemBuzzWord>

     

     

    I could rewrite the umbraco.config so that the file has lowercase entries everywhere on the nodeName attribute but I was looking for a nicer solution. Any ideas?

  • Johan 3 posts 53 karma points
    Feb 28, 2015 @ 15:46
    Johan
    0

    I am using Umbraco v6.2.5 (Assembly version: 1.0.5529.18434)  Mvc config

     

    When looking at the searchbox in the admin interface then that search trhough the nodes are actually case-insensitive. How is that done and were can I find that piece of code?

     

     

  • Johan 3 posts 53 karma points
    Feb 28, 2015 @ 20:58
    Johan
    100

    I solved it by loading the umbraco.config like a xml document and querying it by Linq:

     

           private string getMyNodeidByLinq(XDocument umbracoConfigXml,string nodeName)

            {

                string nodeid = "";

     

                var umbracoNodesCities = from umbNode in umbracoConfigXml.Descendants("City")

                                   orderby umbNode.Attribute("id").Value descending

                                   where umbNode.Attribute("nodeName").Value.ToLower() == nodeName

                                   select umbNode.Attribute("id").Value;

                if (umbracoNodesCities.Count() > 0)

                {

               nodeid = umbracoNodesCities.First();

    }

    }

Please Sign in or register to post replies

Write your reply to:

Draft