Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict items to select by extension in Sitecore8 Internal Link Field

I have an Internal Link Field in a custom template in Sitecore 8. I want the user to use the Link Field to ONLY select a (say) PDF File from the Media Library. When clicking on "Insert Link" the Media Library pops up, scoped to the node I set in the DataSource Field. In here, I want the user to only see PDF files.

Is there any chance this can be done with the Internal Link Field?

Or maybe some other way around that problem? I don't want to have a custom Field Validation that prevents the user from saving the actual item. I'd rather have the user not selecting any "wrong" files for the field.

Thanks in advance.

like image 628
Tim Avatar asked Oct 28 '25 05:10

Tim


1 Answers

Out-of-the box you will not be able to do this. You have a few options that I can think of right now:

  • Change the field type to treelist (or treelistEx) and use Datasource=/sitecore/media library/....&IncludeTemplatesForDisplay=Pdf,media folder&IncludeTemplatesForSelection=Pdf as datasource - your datasource will do exactly what you want but your editors will be able to select multiple pdf's (this can be checked with validation but you wanted to avoid that)
  • Change field type to droplink and use query:/sitecore/media library/....//*[@@templatename='Pdf'] as datasource - now they can only select one, but you get a flat list of items and that might be not that easy to work with
  • Create a custom field type for a link with datasource: this is more work but could give you exactly what you want and it seems like it has been done before.
like image 190
Gatogordo Avatar answered Oct 29 '25 22:10

Gatogordo