Help me to find he image path

ramesh perera asked on April 30, 2014 02:57

suppose that there is a folder in tree node and there are few images within that folder. so how can i get the image path of the First Image within that folder

Please help me to solve this issue as soon as possible Thank you Ramesh

Recent Answers


Alexander Kontsevoy answered on April 30, 2014 04:36

Hi Ramesh Where you want to represent images? If you want do it with DataList web part you can do next 1. Set path to image folder 2. Select CMS.File as "Document Type" 3. In Select top N Documents field enter 1

now you can sort your documents by ascending or descending. Look at "Order By Expression" field. DocumentName ASC sort images in ascending alphabetical order and get first image from the list. DocumentName DESC sort images in descending alphabetical order and get last image from the list. DocumentID ASC - sort images in ascending order by ID of documents (means by order that images was entered in Kentico CMS) DocumentID DESC - sort images in descending order by image ID.

Best regards, Alexander

0 votesVote for this answer Mark as a Correct answer

Alexander Kontsevoy answered on April 30, 2014 04:39

Ups.. I'm sorry. I think, that my answer is not correct on this case :)

0 votesVote for this answer Mark as a Correct answer

Alexander Kontsevoy answered on April 30, 2014 05:43

And again. If you will to apply DataList webpart and apply instructions described me above, and add to ASCX transformation one from next code string them (I don't sure what you want to get as final result. But I hope, that it would be something from this)

Abslosute URL By Document URL: <%# GetUrl(Eval(ResolveMacros("{%CMSContext.CurrentDocument.NodeAliasPath#%}")), GetAbsoluteUrl(GetDocumentUrl())) %>
Absolute URL By Document Link: <%# GetUrl(Eval(ResolveMacros("{%CMSContext.CurrentDocument.NodeAliasPath#%}")), GetAbsoluteUrl(GetDocumentLink())) %>
Document Link: <%# GetUrl(Eval(ResolveMacros("{%CMSContext.CurrentDocument.NodeAliasPath#%}")), GetDocumentLink()) %>
Absolute URL: <%# GetAbsoluteUrl(GetDocumentUrl()) %>

Result on the attached image

Image Text

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 30, 2014 07:18

You need to provide a bit more information as to what your result will be and/or where you are in your content tree.

For instance, if you're on your home page and you want to get the first image in that folder in a different node, you need to:

  • add a repeater or other document listing webpart on the page
  • set the Path = /Your-Folder-Name/%
  • set the Document types = cms.file
  • set Select top N documents = 1
  • set Order by = NodeLevel, NodeOrder, NodeName
  • create a transformation that has the following code <%# GetDocumentUrl() %> (this will simply display the URL of the file on the page for simplicity sake)
0 votesVote for this answer Mark as a Correct answer

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