Matthew Dresser
Matthew Dresser

Reputation: 11442

Use query for the source of a General Link field

Is it possible to modify the General Link field in Sitecore to enable queries to be used in the 'Source' in the template field definition? I'm hoping that it might be possible to add a pipeline processor to handle queries for the General Link field in a similar way that this article describes enabling queries for Treelists and Datasources.

Upvotes: 7

Views: 1449

Answers (1)

jammykam
jammykam

Reputation: 16990

Unfortunately it's not possible with a pipeline since the source resolution does not happen with a pipeline like it does with DropLink field for example.

You can set an absolute path and that works fine... In order to make the source queryable you would have to inherit Sitecore.Shell.Applications.ContentEditor.Link and override the Source property to resolve the query, resolving the query in pretty much the same way you have linked to.

The current implementation does a simple GetItem:

Item obj = Client.ContentDatabase.GetItem(this.Source);

Whereas we need a item.Axes.SelectSingleItem() type query. Unfortunately that means a custom field type or updating the current field type in the core database.

Upvotes: 11

Related Questions