Convert code from a static html to place into a repeater

Dcode warner asked on March 24, 2017 17:59

  1. How can convert the below code into ASCX? {%Documents[CMSContext.CurrentDocumentParent.NodeAliasPath].Children[Documents[CMSContext.CurrentDocument.NodeAliasPath].NodeOrder - 2].NodeAliasPath#%}/

  2. Also need to implement next/previous into blog to go to the next posts. The below only works in the current month. I need all months and all posts to be included.

    < a href="{%Documents[CMSContext.CurrentDocumentParent.NodeAliasPath].Children[Documents[CMSContext.CurrentDocument.NodeAliasPath].NodeOrder - 2].NodeAliasPath#%}/" title="previous room">Back < a href="{%Documents[CMSContext.CurrentDocumentParent.NodeAliasPath].Children[Documents[CMSContext.CurrentDocument.NodeAliasPath].NodeOrder].NodeAliasPath #%}/" title="next room">Next

Recent Answers


Trevor Fayas answered on March 24, 2017 18:43

1: Although a bit messy (you may want to create a Custom Transformation Method to contain this logic)

If(Eval<int>("NodeOrder") > 1, CMS.DocumentEngine.TreeHelper.SelectSingleNode(Eval<int>("NodeParentID")).AllChildren.Where(x => x.NodeOrder == (Eval<int>("NodeOrder")-2)).FirstOrDefault().NodeAliasPath, "")

2:

Since you want to go beyond months, i would recommend you create a custom transformation method since the logic is hard to fit into 1 line, but if you did want to...it would look like tihs mess

CMS.DocumentEngine.DocumentHelper.GetDocuments("CMS.BlogPost").Path(CMS.DocumentEngine.TreeHelper.SelectSingleNode(Eval<int>("NodeID")).Parent.Parent.NodeAliasPath+"/%").OrderBy("BlogPostDate").Where("BlogPostDate > '"+Eval<DateTime>("BlogPostDate").ToString()+"'").Take(1).FirstOrDefault().NodeAliasPath

With the note that the above will ERROR if it's the latest blog post since there isn't one that beyond it, hence why a custom transformation method that can check to see if the object is NULL before calling it's NodeAliasPath would be helpful.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on March 24, 2017 20:50

Is creating Custom Transformation Method available in Kentioc 7. Im googling the documentation to create one.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on March 24, 2017 21:37

This should be the documentation on how to create custom methods for transformations in K7

1 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 25, 2017 01:20

You'll probably need to adjust my logic then, i put it in Kentico 10, so the methods and classes are probably a bit different, Kentico 7 is pretty ancient.

0 votesVote for this answer Mark as a Correct answer

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