Tuesday, October 16, 2018

An Introduction with Sitecore Query



Sitecore has many ways for dealing with items, but in this post, i come to discuss about  'Sitecore Queries'.

Sitecore Query uses an XPath syntax to access  items in sitecore database. However, sitecore query causes performance issue when item number goes high.

Here you see some of the examples

1.  query:.//*    - Get all children from the current page.

2.  query:$home  - Get home item of the current site.

3.  query:..    - Get parent item of the current page.

4.  query:../..  - Get parent of the parent item of the current page.

5.  query:$home//*  - Get every item under home page.

6.  query:$home//*[@@name='keyword']  - Get Every item under home page with additional name filter.

7.  query:..//*[@@templatename='Template name'] - Get every children of the item from current page based on the template given.

8.  query:/sitecore/content/Common/Home/*  - Get all items under path home.

9.  query:/sitecore/content/Common/Home/*[@@templatename='Base'] - Get all items under path home based on a template 'Base'

Some of the XML elements with @@
i) name - Item name
ii) key -Item name with lowercase
iii) templatename -template name
iv) tid - The item's base template GUID.


10.  query:/sitecore/content/Common/Home/*/*[@@templatename='Base'] - Get all items under subfolder of a path based on a template 'Base'

11.  query:/sitecore/content/Common/Home/*/*[@@name='b'] - Get all children under item name exactly matches.

12.  query:/sitecore/content/Common/Home//*[@@templateid='{01182AC6-F3AB-476B-880E-A4B3F6BEEAE3}']  - Get all items under path based on a templateID

// - all children
/  - Immediate Children

13.  query:/sitecore/content/Common/Home/*/*[@@key='top footer menu'] - Get an item based on a key(item name in lowercase)

14.  query:/sitecore/content/Common/Home//*[@@id='{01182AC6-F3AB-476B-880E-A4B3F6BEEAE3}'] - Get an item based on a item ID

15.  query:/sitecore/content/Common/Home/.. - Get parent item of the home element.


Note:
             If your item name has special characters,queries need to be escaped with hash.
             for ex: home/about-us/ needs to be home/#about-us#/ in the form

All is now ready, Happy Coding :)



1 comment:

  1. Sitecore Sources: An Introduction With Sitecore Query >>>>> Download Now

    >>>>> Download Full

    Sitecore Sources: An Introduction With Sitecore Query >>>>> Download LINK

    >>>>> Download Now

    Sitecore Sources: An Introduction With Sitecore Query >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete

Check the users Logged into the sitecore backend

Hi, Today I'm going to discuss about " how to check the concurrent users logged into the sitecore backend ? ". For this ...