Basically, I have a LinkItemCollection property on a block, and when it's displayed I'd like to add special HTML if it's an external link or if it's a file (pdf or word file or similar) rather than an internal episerver page.
I already have an "IsInternal()" method that examines the Href and historically works well, but struggling to find a method to tell the difference between different internal links, page vs image vs pdf etc.
When you have some IContent you can use the standard c# is check
if (content is PageData)
If the type is castable to that type it will be true. Use multiple cases for each on to determine what type it is.
Hi Scott, are you suggesting if it casts to pageData that it is then not a pdf or image or similar? I dont have a concise list of file types it may be.
PageData is the base type for all pages
BlockData is the base type for blocks
MediaData is the base type for all assets
If you need to specificly check for a type check for that e.g. ImageFile if that's the type in your solution to check it's an image.
Thanks Scott, I knew there'd be a reasonally simple way to do it.