Ascx transformation questions

Targutai Yesugei asked on December 10, 2019 07:55

Hello. I want to create an rss-feed which contains amongst all:

  • image
  • category display name (from certain parent category)

  • For image i tried

<![CDATA[<img src="<%# GetAbsoluteUrl(Eval<string>("Thumbnail")) %>" />]]> <%# GetAbsoluteUrl(Eval<string>("Thumbnail")) %> <%# GetAbsoluteUrl(EvalCDATA("Thumbnail")) %>

and all of them returned just a file's guid.

I also tried <%# GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")) %>

and it returns

http://localhost:8066/getattachment/Documents/1-RSS-docs/rss-1/bd9127f3-7ef4-4dd8-ab51-8cf951c0a3b7.aspx

but this link is leading nowhere.

  • For categories I found this transformation

<%# CurrentDocument.Categories.Transform("{#DisplayName#}") %> but I have no idea how receive required display name with it.

Any ideas would be appreciated. Thank you.

Recent Answers


Juraj Ondrus answered on December 10, 2019 08:10

The field where you are storing the image is holding just the GUID of the attachment form the CMS_Attachment table. So, you can also compose the URL manually to look like ~/getattachment/

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on December 10, 2019 10:13 (last edited on December 10, 2019 10:21)

Thank you. You mean to hardcode part of url in transormations, like this: <image>cms/getattachments/<%# Eval("Thumbnail") %></image>

if so, how can I get an image filename by it's guid?

Can you also check second part of my question, about categories?

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on December 10, 2019 10:32

I would recommend using one of the transformation methods for images. And for the categories - there is no ASCX transformation method available - the one you used looks more like a macro, which is not supported in ASCX transformations. I would rather recommend creating a custom transformation and use the API to achieve your need.

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on December 11, 2019 05:19 (last edited on December 11, 2019 05:47)

Thank you.

The problem with transformation methods for images is that they returns the whole image tag, while i need just a link. Can I use something(like regex or smth else) to extract the link from tag code? Also, transformation method GetImage doesn't include the localhost's port to image link, so it becomes <img alt="" src="http://localhost/getattachment/bd9127f3-7ef4-4dd8-ab51-8cf951c0a3b7/rss-1.aspx"/> instead of <img alt="" src="http://localhost:8066/getattachment/bd9127f3-7ef4-4dd8-ab51-8cf951c0a3b7/rss-1.aspx"/> May be the problem won't reproduce when deployed not on localhost, but however it looks suspisious.

I'll also try your advice for categories, thank you.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on December 12, 2019 08:02

The port number is added probably because you are running the project from Visual studio. When running on full IIS, this won't be a problem. And for getting just links, you can use the page and URL methods like GetAttachmetUrl or there are few more options.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.