What I have to expect from GetChildren

Vote:
 

I'm not sure. 

But, when I use GetChildren is it return blocks and pages or just pages?

in this particular code:

var hasChildren = _contentLoader.GetChildren(content.ContentLink).Any();

I'm getting 3 elements, 1 page, and 2 blocks. 

I checked the parentLink is correct. But I have no idea how this was related to this page.

#173144
Dec 15, 2016 6:28
Vote:
 

If you just like pages you should got with GetChildren<PageData> or for blocks just BlockData. Or you can use your own pagetype or blocktype as well. You do not need .Any() either. Not sure why it returns blocks as well in your case. Need more information but my guess is that the IContent is causing this.

Do you have any blocks on the page? Block also is structured the same way if you look in adminmode and access rights you will be able to see all content and not anly pages is structured the same way.

#173160
Dec 15, 2016 14:17
Vote:
 

Ah sorry Any() is needed for you i guess since you are working with hasChildren :) 

#173161
Dec 15, 2016 14:18
Vote:
 

Any IContent, blocks, pages, media. If you need just pages, you can use OfType<PageData>() after GetChildren.

BR,

Marija

#173191
Dec 15, 2016 21:02
Vote:
 

This page has some blocks on Content Area. 

The blocks on Content aren't showing as a Children. I can't find where was add this blocks as children of this page.

On the tree is just on page as children and the same is showing on Access Rights.

Looking to the DataBase these blocks are children of this page. The getChildren are working perfectly. 

What would I like to understand is how is possible to add a block as children of a page? 

#173206
Edited, Dec 16, 2016 1:50
Vote:
 

Ah,OK, I wasn't sure what you were aiming for. They are probably not children of the page, but rather either somewhere in the Blocks folder structure (a folder is their parent) or they are placed in the folder "For this page". Again, the folder is the parent, so you won't get them with get children from the page itself.

You should get them by fetching FilteredItems from the content area instead.

BR,

Marija

#173210
Dec 16, 2016 8:05
Vote:
 

To add blocks as children of the page, you'd need to do it programmatically, by setting the page as their parent.

#173211
Dec 16, 2016 8:06
Vote:
 

Might be better to write the usecase - what you want to achieve from user/editor perspective.

#173212
Dec 16, 2016 8:08
Vote:
 

In this case, I have this blocks just in production. It means that was added by the content team and not from code behind. 

#173753
Jan 09, 2017 0:16
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.