R1、R2、R3 という名前のレシピを含む All Recipes という名前のアイテムがあります。Recipes という名前のツリーリスト フィールドを持つ My Recipes という名前の別のアイテムがあり、All Recipes アイテムから選択された値 R2 と R3 が含まれています。私が書き込もうとしているクエリは、RSS フィードの Items フィールドに対するものです。
[マイ レシピ] の [レシピ] フィールドに表示される [すべてのレシピ] のアイテムを表示するためのクエリ構文は何ですか?
4 に答える
Sitecore クエリでは実行できません。Sitecore.Syndication.PublicFeed
代わりに、拡張およびオーバーライドするカスタム フィード クラスを作成しますGetSourceItems()
。次に例を示します。
public class MyCustomFeed : Sitecore.Syndication.PublicFeed
{
public override IEnumerable<Sitecore.Data.Items.Item> GetSourceItems()
{
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Item contentFolder = master.GetItem("/sitecore/content/Home/MyContentFolder");
//Do your processing here to get your feed items
//I'm just grabbing what's in the content folder, but it could be something complex.
ChildList cl = contentFolder.GetChildren();
return cl;
}
}
RSS フィードの [タイプ] フィールド内の [拡張性] セクションで、カスタム クラスのクラス パスとアセンブリを入力します。
Utility.SitecoreLibrary.RSS Folder.MyCustomFeed, Utility.SitecoreLibrary
このカスタム クラスが代わりになるため、RSS フィードの項目フィールドは空のままにします。
If you're writing this in xslt, you can use sc:listfielditems('fieldname',$item)
to get a node-set of the items in the treelist, which you can then iterate through using for-each
.
If you're writing this in .net, I don't know - but I know a guy who does, and I'll send this his way.
SQL Server を使用していますか? Sitecore のクックブックでは、次のようなことを行うようにアドバイスされています。
MyItems = GetSomeItems("/home/whatever/allrecipes");
foreach(Item item in MyItems)
{
if(item is in MyRecipes)
do something
}
その理由は、/home/whatever/allrecipes のクエリはプロバイダーによって最適化されるのに対し、MyRecipes をチェックする複雑なクエリはよりコストがかかるためです。
参照。
上記のアダムの投稿にコメントすることはできないので、回答として残しておきますsc:listfielditems
。コードを再確認できますか?