【发布时间】:2017-11-14 00:16:33
【问题描述】:
在 Sitecore 内容树中,我有一个包含大约 3000 篇文章的列表。每篇文章都有一个作者字段。作者字段的类型为 droplink。我正在尝试编写一个 PowerShell 脚本,以获取每位作者撰写的文章的计数。
#This is where all the Authors lives
cd 'master:/sitecore/content/mysite/Global/Authors Folder'
#Get all the articles that each author has written
function ProcessItem($item)
{
$articles = Get-Item master: -Query "/sitecore/content/mySite/Home/Articles/2017//*[@@templatename='Article' and @Author='$item.Id']"
$articles.Count
}
#Get a list of authors
$itemsToProcess = Get-ChildItem -Recurse . | Where-Object { $_.TemplateName -match "Authors" }
if($itemsToProcess -ne $null)
{
$itemsToProcess | foreach {ProcessItem($_)}
}
通过作者 ID 获取文章的调用似乎没有返回任何内容。因此$articles.Count 总是返回 0。我尝试到@Author.Value='$item.Id' 但仍然没有得到任何结果。谁能看到我在这里做错了什么?
【问题讨论】:
标签: powershell sitecore sitecore8 sitecore-mvc sitecore7.2