13

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 you can (probably) work around it using some of the suggestions already given. Escape the query like .../#Self Service#/ - but this will only work if you plan ...


12

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 (results include items with versions that match the query in any language) Fast query does not support sorting (sort results after querying) In a fast query, ...


9

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&DatabaseName=web You can also then add any other parameters for including/excluding templates etc...


8

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 of your Treelist field to the following: query:self:: This will select the current item as the root of the Treelist field.


8

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 rendering cache on top, of course). So, you can define your custom POCO object with IsInFooter and IsInHeader fields and query your index. Simplified code (...


8

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.Item.Children Model.Item.GetChildren() Item.GetChildren() method can take ChildListOptions as the parameter. Here are available flags: ChildListOptions.None ...


8

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 - if you fast query a single item, you will get a single item. If your fast query adds children or all descendants you will get what you asked for. This is the ...


8

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 Folder' and contains(@@name, '" + year + "')]" List of supported functions: contains('does this string', 'this string') startswith('does this string', 'this ...


7

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.Data.Query.ParseException: End of string expected at position 77. It should look like this when the string is formatted: /sitecore/media library//*[@@id='{...


7

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.GetReferrers($rendering) | Where-Object -FilterScript { $_.SourceFieldId -eq '{04BF00DB-F5FB-41F7-8AB7-22408372A981}' -or $_.SourceFieldId -eq '{F1A1FE9E-...


6

You can access MongoDB directly through the C# driver: string connectionString = ConfigurationManager.ConnectionStrings["analytics"].ConnectionString; var client = new MongoDB.Driver.MongoClient(connectionString); var database = client.GetServer().GetDatabase("your_database_name"); var contacts = database.GetCollection("Contacts"); var results = ...


6

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 in a path to an item that does not exist, it will not be able to work out an ID. If you want to make sure that Datasources are set when the item is created, a ...


6

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'] Documentation link (old, but I could not find any more recent): https://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/...


6

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 using Parameterized datasource, which allows you to add some additional restrictions as well as setting the root node. datasource=/sitecore/content/location/to/...


6

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 you can use SPE to query items. Option 1 Your case is similar but may be a little expensive. In that case the Sitecore Content Search API may be ideal for you....


6

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 hierarchy of navigational items define what they show. But that's a separate story. Content Search As already demonstrated by @Andrey Bobrov. Performance wise, ...


6

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 fields. While proving a negative is impossible, I checked the following guides. None of them list &DatabaseName=xxx as a valid parameter for the search ...


6

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-server-or-website/ But if you still want to use here is the trick: The field in Sitecore is not Display Name, it is "Display Name". All the standard ...


6

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 = Database.GetDatabase("master").GetItem(countryItemID); if (countryItem != null) var allFirstLevelChildren = countryItem.GetChildren(); This should return ...


5

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 renderings that have a datasource linked to one of the children. The first step was to get the items that I needed for the datasource: the original one (in the ...


5

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.IsDescendantOf(Item item) which can be used as follows: currentItem.Axes.IsDescendantOf(i).


5

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 allow the user to select from virtually any page on the site, allowing them to navigate the site to pick entries is a good idea. Programmatically, Treelist ...


5

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.com/2011/03/using-source-property.html


4

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, you can configure a list of area resolving strategies, which are responsible for resolving the area for the current rendering: Each strategy is called after each ...


4

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 because the LongID property contains a string representation of all parent item GUIDs and since the item GUIDs are unique you can rely on it only matching if they are ...


4

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:{7826b36e-d813-40cf-aa33-26132ff2dad6};sort:published[desc] where published is field of an item. Use your field there.


3

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. When you look at Experience Profile, the data you see if coming from an API call to /sitecore/api/ao/v1/aggregates/latest-visitors. Tracking that back to the ...


3

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. When a new item is added, if it is added from a branch template then datasources pointing under the branch template will update to the relative to the current ...


3

Root cause was - Item existed in EN version and when trying to preview in other language it should fallback to EN. Now twist here was EN version had publishing restrictions so effectively item didn't existed in any language versions which somehow gives error, from Item-level Language Fallback module, in page when trying to use preview mode. I have fixed ...


3

Can you try this /sitecore/content/Abcdef/Sites/WXYZ/MNO/Application Contexts/Connect On Demand/Sections/#Self Service#/* Which handles escape sequence i.e. space in itemname


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