Get Children Recursively in Sitecore CMS .NET - sitecore

Does anyone know how to recursively get the children of an item in a Sitecore web control? I'd rather not use Sitecore query because some of my paths have dashes in them which really screws things up. The Sitecore.Context.Item.getChildren() and Sitecore.Context.Item.Children property both returned just the top level children.

From Sitecore, looks like the way to do this is Item.Axes.GetDescendants()

Related

Big Lists in Umbraco 7

We are migrating our site from SharePoint to Umbraco 7, what is the best way to store & manage lists in Umbraco? in the current site in SharePoint We have a lot of lists.
NestedItems is not a very good solution because there is no option to search in or sort.
Thanks
For each type of list you have, create a node that's configured to have a list view, then add each list item as a subnode to the parent node.
That way you get a good solution performance-wise, and you'll be able to search through the subnodes.
(Screenshot is from Umbraco 8, so UI to enable List View may be a little different from Umbraco 7, but the concept is the same)
You have a couple of options, depending on what you need to achieve.
If you want to use the default Umbraco index for your content, you can create a doctype and enable list view on it, then any children of that node will be in a searchable/orderable list.
If you want to store the data in a custom database table, there is a package called Fluidity for Umbraco 7 which allows you to easily integrate this into the backoffice.
https://our.umbraco.com/packages/backoffice-extensions/fluidity/

How can I create children of a non-existent parent page in the Wagtail CMS for Django?

I want to create children of a page (such as "/questions/example"), without having to create the root page "/questions". Is there a quick way of implementing something like this?
Child pages need to be, well, children - so there's no easy way to get around this.
However, if what you're asking is "I want to have /questions/foo/ without having to have a page accessible at /questions/", two options are:
add a new QuestionsPage to your project, add it as a child of the root, save as a draft and don't publish it - you'll then be able to add child pages to it and publish those, but anyone going to /questions/ will get a 404. This 'works' but isn't super-nice
add a StructuralPage (or similar naming) to your project, and override the serve() and serve_preview() methods to redirect to the homepage (or somewhere else) if someone accesses them. You can add child pages to that, etc, as above.

Identify page nodes that have specific layout controller

I would like to search all pages that have a specific(based on GUID) layout controller node. Is there a way to do this in Sitecore?
I am hoping to avoid going through all the page nodes and identifying the layout controller via the presentation detail. This would be a tedious tasks if I have to do so.
You can also go to the layout in sitecore and click on the "Navigate" ribbon and use the "Links" menu option. The Referrers are the items that use the layout.
You can use the Development Center for it.
Go to the Sitecore Menu -> Development Tools -> Developer Center
Then, Select Tools -> XPath Builder.
The query you need is like this:
/sitecore/content//*[contains(#__Renderings, '{A5437488-E6FA-42D3-B201-25D3CFE0A02B}')]
Find all items that contain a specific id on the __Renderings field.
The __Renderings is a field like any other. It stores the information about the layou, devices and renderings. That said, you can use Sitecore queries to find items based on it. See:

How to implement sitecore site search

I need to implement content site search based on sitecore API.
I know how to set up crawler for Lucene.Net, but this would be some kind of search by predefined template, I need to implement search by result content (final html), it should works like close to google search. Is is possible to do in sitecore ?
Thanks.
If you want the search to be based on the rendered HTML (are you really sure about that), some custom magic is required.
Crawling the content is needed in such case, thus if the publised item is visitable (has an URL), you can use the HTMLAgility framework to get the HTML, strip the tags and add the content to the index in any (new) field you like...

Find all the item that is using a common Sublayout in sitecore 6.2.0

Is it possible to obtain a list of all the items in sitecore that is using common sublayout or XSLT's in presentation tab for rendering i.e. suppose there is sublayout called layout1.ascx that is being used by 5 items.is it possible to obtain the list of all these 5 items by search method.
Thanks in advance.
Regards,
Divya
You probably need to do this in two steps (or one if it's only 1 template).
You need to use the Link database.
The simplest way of seeing these "links" is to go to the Sublayout or Rendering and go to the "Navigation" menu and then click on "Links". This should show you all the items that point to this current item and all the items that the current items points to (ie. both ways).
This will probably give you a list of templates and/or items (if the sublayout is set directly on an item).
Then go to a template and see how do the same to see which items are have a refernce to the template.
This should show you which items are using which sublayouts.
Of course this requires the Link database is up to do (should be done automatically, but you can force this with Start > Control Panel > Databases > Rebuild Link Database) and that the Sublayouts etc are bound in Sitecore..
I hope this helps.
The Link database suggestion is great, but if your sublayout is used by hundreds of items, it may take a little while to load.
Another alternative is this fast query:
fast://*[#__Renderings='%{FAAD00AE-A089-4AEF-989C-73917660FF48}%' or #__Final Renderings='%{FAAD00AE-A089-4AEF-989C-73917660FF48}%']
This can be run in the developer center, under Tools > XPath Builder (or for Sitecore 8.x the XPath Builder can be found at /sitecore/shell/default.aspx?xmlcontrol=IDE.XPath.Builder).
Sitecore 9.x no longer supports the XPath Builder, but you can still run this if you install the Sitecore PowerShell Extensions.
The following command can be run:
Get-Item -Path "master:" -Query "fast://*[#__Renderings='%{FAAD00AE-A089-4AEF-989C-73917660FF48}%' or #__Final Renderings='%{FAAD00AE-A089-4AEF-989C-73917660FF48}%']"
Change the guid above as needed.