GeekInTheBox
GeekInTheBox

Reputation: 149

Querying Sitecore Content Item Data Fields With Spaces in Data Field Name

Please be gentle...I'm very new to Sitecore development.

So the following returns the value from any data field associated with a content item...as long as the data field name has no spaces in it

    #foreach($item in $genie.QueryPageItems("/sitecore/content/Sparklev2/articles/*"))
       $item.Name - $item.Copyright - $item.Body Tag Css 
    #end

and the method it is calling (written by another developer):

    public List<PageItem> QueryPageItems(string query){
        return (from item in Sitecore.Context.Database.SelectItems(query).ToList<Item>() select new PageItem(item)).ToList<PageItem>();
    }

The above returns the name and the copyright fine, but not the body tag css values. I have wrapped body tag css in everything I could think of but cannot make this work. Am I missing something or is this just not possilbe

Upvotes: 0

Views: 2833

Answers (1)

Mark Cassidy
Mark Cassidy

Reputation: 5860

You need to escape special characters and space.

/sitecore/content/#Sparkle V2#/articles/*

On a separate note; it's gonna perform donkeys. But escaping is your answer.

Upvotes: 3

Related Questions