Sitecore - return to parent bucket

Hi guys, I have a question about bucket elements in Sitecore.

I have the following structure:

enter image description here

I want to create a button on the "test" page, which will return to the top bucket "News Overview".
Usually I would do something like:

LinkManager.GetItemUrl(Sitecore.Context.Item.Parent)

The problem is that the direct parent is the bucket "44" and not the "News Overview".
What would be the best way to link to the survey bucket?

Thanks in advance!

+4
source share
2 answers

The element has an extension method that gives you the bucket element of your current element.

Its in the namespace Sitecore.Buckets.Extensionsin the assembly Sitecore.Buckets.dll.

:

var bucketItem = Sitecore.Context.Item.GetParentBucketItemOrParent();
var urlToBucket = LinkManager.GetItemUrl(bucketItem);

BucketManager, , :

BucketManager.IsItemContainedWithinBucket(Sitecore.Context.Item)
+10

[Sitecore.Data.Items.Item].Parent , , , , .

[Sitecore.Data.Items.Item].Axes.GetAncestors(), Item .

/ , Sitecore 7. , , Sitecore 6, Sitecore 7.

+1

Source: https://habr.com/ru/post/1533159/


All Articles