Skip to main content
13 votes
Accepted

Sitecore Query fails - "::" expected at position 92

The problem You are running into one of many inherent problems with using Sitecore Query. The problem is; self is a reserved word - and therefore /Self Service/ fails. Workarounds Now in this instance ...
Mark Cassidy's user avatar
  • 25.4k
12 votes
Accepted

What are the limitations of Fast query?

Article by John West I came across a nice article written by John West which provides important information for developers. Known limitations: Fast query does not account for the context language (...
Michael West's user avatar
  • 18.5k
10 votes

Is there a way to reference another database in Multilist with Search

Yes - in the source property of your field item, you can use the parameter DatabaseName to set the name. So you might have something like: DataSource=/Sitecore/Content/MySite/Subscriptions&...
Richard Seal's user avatar
  • 20.7k
9 votes
Accepted

Get Current Item children by fast query

In theory the correct syntax is query:. (. being self) but there is a bug which means it does not work as expected. I would recommend not using fast: for performance reasons, instead set the Source ...
jammykam's user avatar
  • 13.9k
9 votes

Get all Children in the order defined in Sitecore

Fast query runs on the database directly. In most of the scenarios it's not an ideal choice. If you want to get children in the same order as they are defined in Sitecore, use Sitecore API. Model....
Marek Musielak's user avatar
  • 24.1k
9 votes
Accepted

using sitecore queries to search for items whose names contain a specific string

Sitecore query supports various axes, functions, and operators similar to those used in XPath. You can use The contains() function as follows: string query = path + "//*[@@templatename = 'Template ...
Ahmed Okour's user avatar
  • 2,134
8 votes
Accepted

Creating a very large footer menu efficiently

The question is quite broad and there are many ways you can achieve this obviously (you mentioned sitecore query and foreach loop). Another option would be to use the sitecore content search (with ...
Andrey Bobrov's user avatar
8 votes
Accepted

How to query for items under @@id with specific @@templateid

First: Don't use fast query, use your index (Sitecore.ContentSearch). "fast" query is actually very slow by comparison. The query you tried is malformed, that's why you see this message: Sitecore....
Nathan Hase's user avatar
8 votes
Accepted

Why we should not use fast queries in Sitecore

Everything that @Hishaam said is correct, but I want to clarify the 2 questions here: So if I fast query an item with 100 children will all those come in to memory without paging or caching? No - ...
Richard Seal's user avatar
  • 20.7k
8 votes
Accepted

Getting all items using a Specific Sublayout using Sitecore Powershell Extensions

Yes you can. I would go through the Links database in order to do that, like this: $rendering = Get-Item -Path '{093B75B4-5060-4F3D-AFAB-DCA4999F7E96}' $items = @() [Sitecore.Globals]::LinkDatabase....
morten.engel's user avatar
7 votes
Accepted

Get all items where a certain template appears in its template inheritance

Sitecore PowerShell Extensions At first your question made me think of this where the user wants to find media items of a certain length. I encourage you to check that out to see some different ways ...
Michael West's user avatar
  • 18.5k
7 votes
Accepted

Set relative datasource for rendering

I'm going to try and make this not a link only answer. What you are trying will not work because the renderings fields (shared and final) want to store the ID of the data source item. If you just type ...
Richard Seal's user avatar
  • 20.7k
7 votes

Get all Children in the order defined in Sitecore

Welcome to Sitecore. If you want to have the first level children of an item use: selectedItem.GetChildren() There are many ways to implement this so below is just one example: var countryItem = ...
Leonardo Cunha's user avatar
6 votes
Accepted

How to Join MongoDb Collections Using Sitecore Mongo Db Report Data Source

You can access MongoDB directly through the C# driver: string connectionString = ConfigurationManager.ConnectionStrings["analytics"].ConnectionString; var client = new MongoDB.Driver.MongoClient(...
Dmytro Shevchenko's user avatar
6 votes

How to use Sitecore Item Web Api and query for a Sitecore item with a particular value in the field?

I believe the problem is the hash (#) signs instead of quotes (') around values. This is a sample query from the Item Web API documentation: /sitecore/content/Home/*[@Title='Welcome to Sitecore'] ...
Jonas Hamnered's user avatar
6 votes

Creating a very large footer menu efficiently

There are only two viable options; short of simply not building up navigation structures in this manner. I would normally have any form of navigation being components of their own, and have a menu ...
Mark Cassidy's user avatar
  • 25.4k
6 votes
Accepted

Retrieving multiple items in treelist query

The reason only the first result is available for selection is because the treelist query sets the root item for selection, not the available list of items. Instead you should use enhanced syntax ...
jammykam's user avatar
  • 13.9k
6 votes

Is there a way to reference another database in Multilist with Search

No. Doesn't appear to be, out of the box While my initial instinct was, that @Richard Seal's answer was correct, I don't actually see any documentation stating that this will work with search driven ...
Mark Cassidy's user avatar
  • 25.4k
6 votes

Get item by Display name in sitecore

First of all I do not recommend using FastQuery, because it can be really slow and many people have had problems with it: https://blog.coates.dk/2014/11/19/sitecore-fast-query-syntax-can-kill-your-sql-...
Vlad Iobagiu's user avatar
  • 18.7k
5 votes
Accepted

Is it possible to use a Sitecore query to set an item's data source?

As mentioned in my comment, I noticed on a project that it was not possible to use queries in a datasource field. I had a branch template that created some children and the parent item might have ...
Gatogordo's user avatar
  • 20.2k
5 votes

Site navigation - how to best to set the active class of all parent items of the current context page item?

There's a method that does basically what jammykam initially suggests. It uses StartsWith but that really shouldn't ever matter when comparing long ids. It is Sitecore.Data.Items.ItemAxes....
Teeknow's user avatar
  • 2,477
5 votes

Multilist source query to exclude items whose parent has a specific template id

I would suggest switching your field technology from a Multilist to a Treelist. The treelist allows the user to see the context of the object they're selecting. Considering that you're offering to ...
sitecorerick's user avatar
  • 2,329
5 votes

Fieldsource query for droptree field

Yes is possible to have a query source like query:./ancestor-or-self::*[@@templatename='Site']/Data/Components/* Have a look on this link how to use sources for fields: http://sitecore.wonderamy....
Vlad Iobagiu's user avatar
  • 18.7k
5 votes

Need help with a Query to select a data source context, for each site

What you need to do is walk back up the tree to your Site root item and then path down to the Datasource folder you need. You can do it something like this: query:./ancestor-or-self::*[@@templatename='...
Richard Seal's user avatar
  • 20.7k
4 votes
Accepted

Where to find Visit Duration and Latest Date Visited in Code Behind

That data is in the sitecore_analytics_index. It is not in the analytics model for you to pull from. You are going to have to make a call into the index to get that data for each of your contacts. ...
Chris Auer's user avatar
  • 13.2k
4 votes
Accepted

MVC Areas using with Sitecore 8.2 Update1

For each MVC rendering, the pipeline mvc.renderRendering is called. In the Sitecore.Mvc.config there is a new processor ResolveArea configured for this pipeline. Within the processor configuration, ...
Vlad Iobagiu's user avatar
  • 18.7k
4 votes

Site navigation - how to best to set the active class of all parent items of the current context page item?

The simplest option is to check if the Paths.LongID property of the current page item contains the menu item ID. @Html.Sitecore().CurrentItem.Paths.LongID.Contains(i.ID.ToString()) This works ...
jammykam's user avatar
  • 13.9k
4 votes

How to sort items in a query inside a variant?

While using Variant Query you can use: normal Sitecore query Sitecore content search query Try something like this: +template:{7826b36e-d813-40cf-aa33-26132ff2dad6};sort:published +template:{...
Dawid Rutkowski's user avatar
4 votes
Accepted

Sitecore 10.1 Fast Query CompositeDataProvider System.NullReferenceException

Fast:// Query is not supported in Sitecore 10.1 and onwards. Sources: http://www.stockpick.nl/english/the-end-of-sitecore-fast-query/ Official Source: https://dev.sitecore.net/Downloads/Sitecore%...
Mark Cassidy's user avatar
  • 25.4k
3 votes

Is it possible to use a Sitecore query to set an item's data source?

There is a solution out there to help deal with this in a different way. Using the linked solution called Branch Presets, you would set your datasource as a normal, full path in your branch template. ...
Teeknow's user avatar
  • 2,477

Only top scored, non community-wiki answers of a minimum length are eligible