Pull data from another page through repeater to current page.

Dcode warner asked on February 22, 2017 23:10

Is there a code where I can find/locate data/field from an exiting transformation on another page and full that to a current page inside another transformation?

(Example page: "Players.aspx" ) Tom Brady <%# Eval("footballName") %>

Without duplicating the content in the CMS desk at all. Pull just that data?

(Example page: "AllPlayers.aspx" ) Tom Brady

Recent Answers


Ilesh Mistry answered on February 22, 2017 23:30

Are the pages linked in any way e.g. Related pages or linked pages etc...? As this could help with what you can use.

One approach is to create a custom function to be used in the transformation, where you can supply a path or node ID or document ID and also a field name. Then that function would find that specific page and return the field way. This link should help with the code you should be using Document Query API and also adding custom functions to transformations

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on February 22, 2017 23:30

Yes, anything that can be gotten through Kentico's API can be used in the transformations.

Example:

<%# CMS.DocumentEngine.DocumentHelper.GetDocuments().WhereEquals("NodeAliasPath", "TheNodeAliasPath").FirstObject.GetValue("FootballName") %>

Another option is if you use a Repeater with Custom Query, you can generate a query that pulls in the information through Join statements and transform that.

Just be careful with your logic, it can slow up your repeater results and you will want to properly use Cache, CacheHelper, etc in order to make it speedy!

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 22, 2017 23:57

@Trevor Fayas For clarification. "TheNodeAliasPath" is the URL example: /Gallery

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on February 23, 2017 00:16

Not sure i follow you, but mainly just pointing out if you have a reference to the object you want to pull from (node alias path, id, etc) you can use similar to that to get it. If you need further help and can't get it just provide some additional information on your structure and such!

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 23, 2017 00:39

Alright. From looking at your code. I'm trying to understand where in the script says."Get the data from this page". So would the below be correct. Let me know if you understand.

<%# CMS.DocumentEngine.DocumentHelper.GetDocuments().WhereEquals("/Gallery", "TheNodeAliasPath").FirstObject.GetValue("FootballName") %>

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 23, 2017 01:53 (last edited on February 23, 2017 01:59)

Keep in mind on each iteration in your repeater you might produce an extra query. I would revise the architecture i.e. your data source or source query for your repeater should have the all the necessary data. Extra join in SQL query is much better than SQL query on each iteration.

If really want to have a nested repeater - it is possible take look at nested controls

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 23, 2017 14:43

For this scenario, I'd not create any custom code or complex solutions. The easy solution for this which DOES NOT duplicate the data is to place a linked page under the place in the content tree you want it to show up. Linked pages allow you to have the same exact content and properties with a different URL or path.

For instance:

/Teams
/Teams/Team-1
/Teams/Team-2
etc.

/Top-Performers
/Top-Performers/Team-2
/Top-Performers/Team-4

The Team-2 and Team-4 will have different node and document ID's as well as paths in the content tree but all the other properties are exactly the same. So if you make a change under /Top-Performers it will replicate to the /Teams node too. If you have a 3rd node with these linked documents in, it updates them as well.

This is the benefit of a CMS, the same content in different locations and manage it in one location.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on February 24, 2017 02:05 (last edited on March 7, 2017 18:49)

Thanks

0 votesVote for this answer Mark as a Correct answer

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