Field Data Type: Hyperlink
This explains Hyperlink Fields. For an overview check out Understanding Data....
Hyperlink data is a basic data type and is actually a string, but on reading it's automatically converts to an output-friendly format. It's used for normal links, page or file/image references as well as for complete sets of files (like image galleries).
Features
The basic hyperlink (links/files) field is used for normal links, page or file/image references as well as for complete sets of files (like image galleries)
Sub-Types of Hyperlink Fields
- hyperlink-default - it's input field for normal links, page or file/image references. In menu it has ADAM (automatic digital asset manager), page picker, image manager and file manager.
- hyperlink-library - it's for complete sets of files (like image galleries).
Shared Settings
All Hyperlink-Field Types have the following settings:
File Filter - list of extensions allowed in file/image picker. Example: .jpg,.bmp,.png,.gif
Paths - this is only needed if you use the old file pickers (not ADAM). Root paths for the picker dialog - ideal if you want all images for this Content-Type to be in the same folder
- use the syntax foldername - without "/" in front to specify a subfolder of the site-root. Examples are "Apps" or "Gallery" or "Employees/Photos"
- you can also use subfolders - that would be "Employees/Photos"
- always remember that this folder must already exist, and Dnn must know that it is visible (readable) by the editing user. There are cases where the security settings were not set correctly in dnn - then the file picker won't show anything.
Default Dialog - none, ADAM, page picker, image manager or file manager
Show Page Picker - show page picker in the drop-down
Show Image Manager - show image manager in the drop-down
Show File Manager - show file manager in the drop-down
Show Adam - show the ADAM (automatic digital asset manager) in the drop-down menu.
Buttons - will let you specify which buttons are visible directly. The default is "adam,more" but you could also do "adam,page,more" or just "page". File / image are currently not supported, because as of now, Dnn doesn't have a good image/file browser so we discourage its use.
Automatic Conversions of file and page references
The hyperlink data internally can contain values like:
http://whatever/whatever
- will not be converted/some-relative-url
- will not be convertedpage:42
- will usually be converted to the real url of the page in Dnnpage:42?something=value
- this will also be converted, but keeping the parameterspage:42#something=value
- this will also be converted, but keeping the parametersfile:2750
- will usually be converted to the real url of the file in Dnnfile:2750?w=200
- this will also be converted, but keeping the parameters (like for thumbnails)file:2750#page=2
- this will also be converted, but keeping the parameters (like for pdf-page-links)
In 99% of all use cases, you want to generate html with a real link, which is why the content-objects in Razor will deliver an http:...
instead of file:27
. Some demo-code:
// assume that Content is a dynamic entity
// assume that Image actually contains "file:274"
<img src="@Content.Image">
// the result is now
<img src="/portals/0/adam/20603963uaothutaoer/daniel.jpg">
Accessing the Real Inner Value
In rare cases you may want the originl page:22
instead of the converted value. To do this, use AsEntity(yourObject)
and then use the EAV API on IEntity to read the underlying original value.
Special: Hyperlink Libraries
A special use case is Libraries - where a hyperlink-field doesn't actually contain anything, but is a placeholder for ADAM assets.
In such a scenario, you will use AsAdam(...)
in your code to get the folders/files in the ADAM repository.
Null Value Possible
In some cases you may add a field to a type which already has Entities created previously. In this case the old data doesn't have a value for the field.
If this happens, the field will return null
, so you may need to catch this special exception in your code.
A common shorthand to work with this is either the
??
operator or using RazorBlade withText.Has(...)
orText.First(...)
.
Technical Information
Storage in the SQL Database in the EAV-Model
This is simply stored as a string in the DB, in the original format like page:22
.
Storage in the SQL Database in the JSON-Model
This is simply stored as a JSON string in the original format like page:22
.
Read also
History
- Introduced in EAV 1.0 / 2sxc 1.0
- Changed in EAV 3.0 / 2sxc 6.0 (it used to have many configuration fields for all kinds of uses, which were then moved to sub-types)