0

How can I check if particular expected item is content and datasources

 foreach($baseItem in $listOfPages) {
        $items += Get-Item $baseItem.Paths.FullPath 
        $items += Get-ChildItem $baseItem.Paths.FullPath -Recurse 
  }

2 Answers 2

1

It's hard to know what you mean by "is content and datasources".

You can call

$baseItem.Paths.IsContentItem

that will return true is descendant of /sitecore/content item.

And you can

  • $baseItem.Template
  • $baseItem.TemplateID
  • $baseItem.TemplateName

values to get more information about what kind of item that is.

2
  • Not always but datasources tend to have no layout. May 26 at 13:04
  • To be sure if the item is content of page or page item itself May 26 at 13:10
1

So you can check if the item is a Content or Datasource using this way also.

$renderingInstance = Get-Rendering -Item $baseItem -Rendering $rendering
 
if($renderingInstance)
{
    Write-Host "content item"
}
else
{
    Write-Host "datasource item"
}

You can implement this logic with your code. Hope this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.