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 ...
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 (...
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&...
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 ...
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....
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 ...
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 ...
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....
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 - ...
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....
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 ...
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 ...
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 = ...
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(...
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']
...
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 ...
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 ...
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 ...
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-...
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 ...
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....
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 ...
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....
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='...
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.
...
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, ...
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 ...
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:{...
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%...
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. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sitecore-query × 101sxa × 10
datasource × 9
tree-list × 7
sitecore-client × 6
solr × 5
sitecore-api × 5
querybuilder × 5
content-search × 4
powershell-extensions × 4
multilingual × 4
templates × 4
content-editor × 3
mongodb × 3
rss × 3
presentation × 2
upgrade × 2
mvc × 2
powershell × 2
fieldtype × 2
language-fallback × 2
buckets × 2
custom-field × 2
sitecore-commerce × 1
jss × 1