Hi Kyle,
How are you registering the control in the transformation?
Also, what form control is used for the attachments? Is it a single attachment (File upload) or Document attachments control?
For single file, like image teaser, you could use e.g. the GetFileURL method or GetImage (transformation methods). The image field must be indexed and set e.g. as content or searchable.
If you are using document attachments, you will need to create custom method, something like this, where you will use the document ID:
Attachments on FORM tab
int documentID = 988;
string attachmentFieldColumnName = "MyAttachmentsField";
string className = "cms.news";
string htmlCode = null;
// get form definition of class
var formInfo = new FormInfo(DataClassInfoProvider.GetDataClassInfo(className).ClassFormDefinition);
if (formInfo != null)
{
// get attachment field definition
var attachmentsField = formInfo.GetFormField(attachmentFieldColumnName);
if (attachmentsField != null)
{
// attachment guid
var fieldGUID = attachmentsField.Guid;
// get attachments for given document and field
var attachmentsOfField = AttachmentInfoProvider.GetAttachments().Where("AttachmentGroupGUID", QueryOperator.Equals, fieldGUID).And().Where("AttachmentDocumentID", QueryOperator.Equals, documentID);
foreach (var attachment in attachmentsOfField)
{
// get url of attachment
string attachmentUrl = URLHelper.GetAbsoluteUrl(AttachmentURLProvider.GetAttachmentUrl(attachment.AttachmentGUID, DocumentContext.CurrentDocument.NodeAlias));
// append html code with the url
htmlCode += "<a href=\"" + attachmentUrl + "\">" + attachment.AttachmentName + "</a><br>";
}
}
}
Attachments including Properties -> Attachments:
[9:59:23] sup_Richard Šůstek: var attachmentOfDoc = AttachmentInfoProvider.GetAttachments(988, false);
foreach (var attachment in attachmentOfDoc)
{
// get url of attachment
string attachmentUrl = URLHelper.GetAbsoluteUrl(AttachmentURLProvider.GetAttachmentUrl(attachment.AttachmentGUID, DocumentContext.CurrentDocument.NodeAlias));
// append html code with the url
htmlCode1 += "<a href=\"" + attachmentUrl + "\">" + attachment.AttachmentName + "</a><br>";
}