I need to access an ID to an adam file setup like this:
MyDocument is the field name, where users can load an image or whatever. In a list style view, users will click a link that activates a detail view for that image.
The link will be something like mysite.com/mytab/detailsforfile/fileId
The details view will parse the fileId and load the image.
So, two questions:
Is the native DNN file: 123 the only way? Or does 2sxc or adam have some specific ids?
Edit: A practical example would probably help:
This list view will have:
@foreach(var car in eCars) {
<div>
<strong>@car.Name</strong>
<img class="img-fluid" src="@car.carImageOne">
<a href="@("/whatever/" + IDFORTHISIMAGE)">See full image...</a>
<img class="img-fluid" src="@car.carImageTwo">
<a href="@("/whatever/" + IDFORTHISIMAGE)">See full image...</a>
</div>
}
And the details view:
@{
var qsImageId = Request.QueryString["whatever"];
//cast and double check the qs int
var imageURL = ??; // How do I get the file url based on the id?
}
<div>
//embed nice frame, ads, whatever
<img class="img-fluid" src="@imageURL">
</div>
convertLinks: false
- see https://docs.2sxc.org/api/dot.net/ToSic.Sxc.Data.IDynamicEntity.html#ToSic_Sxc_Data_IDynamicEntity_Get_System_String_System_String_System_String_System_Boolean_System_Nullable_System_Boolean_ _Alternative is to pass the entity-id to the details page, and there just get the entity and work with that - which is probably much easier.
To get the file ID I used this:
var getFile = AsAdam(Entity, "field").Files as System.Collections.Generic.IEnumerable<dynamic>;
get fileId = getFile.First().FileId;
To get the url from the id:
var myFile = FileManager.Instance.GetFile(FileId);
var myurl = FileManager.Instance.GetUrl(myFile);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.