ASPX templates
Version 5.x > ASPX templates > Document Type Parent View modes: 
User avatar
Member
Member
lwhittemore-emh - 11/17/2011 3:05:39 PM
   
Document Type Parent
on my site I have several pages set up like this " Page -> folders -> Documents"
Each page has the same folders below it each with documents in the folders. The documents all use the same document type.

On the home page I use a repeater with a transformation that pulls the content from the other pages all into one big list on the home page.

Is there a way to get the Page Title that the document is under to display on the home page without having to add it as an extra field in the document type.

For example, I have a page Called "Field Hockey" with a "Tournaments" folder under it. When I pull a document from the "Field hockey / Tournaments" folder on the home page is there a way to get the "Field Hockey" page title to show on the home page?

User avatar
Certified Developer 9
Certified Developer 9
charbf - 11/17/2011 8:40:30 PM
   
RE:Document Type Parent
Hi

you can use

CMSContext.CurrentDocument.Parent.DocumentName

or

CMSContext.CurrentDocument.Parent.GetValue("AnyField")

User avatar
Member
Member
lwhittemore-emh - 11/18/2011 7:15:30 AM
   
RE:Document Type Parent
Thanks for the reply! However, I am not much of a coder and do not know how to add that to my transformation.

User avatar
Certified Developer 9
Certified Developer 9
charbf - 11/18/2011 8:13:19 AM
   
RE:Document Type Parent
Hi,

Instead of <%# Eval("AnyField") %> you can put these. Make sure you respect the caps


<%# CMSContext.CurrentDocument.Parent.DocumentName %>

or

<%# CMSContext.CurrentDocument.Parent.GetValue("AnyField") %>


User avatar
Member
Member
lwhittemore-emh - 11/18/2011 8:19:24 AM
   
RE:Document Type Parent
I get this error.

[CMSDataProperties.LoadTransformation]: http://server/CMSTransformations/feae4689-24cd-4153-81dc-7147c0de85b2/fieldsforkids/article/newssummary.ascx(3): error CS0117: 'CMS.TreeEngine.TreeNode' does not contain a definition for 'Parent'

This is what my transformation looks like
<h3><a href="<%# GetDocumentUrl() %>"><%# CMSContext.CurrentDocument.Parent.DocumentName %> - <%# Eval("Title") %></a></h3>
<p><%# Eval("Summary") %></p>


Do I need to add anything to the code behind? The team that I would uses VB over C# if that makes a difference.

User avatar
Certified Developer 9
Certified Developer 9
charbf - 11/18/2011 12:25:32 PM
   
RE:Document Type Parent
Hi,

this is only available with version 5.5R2 and up.


As for VB/C# I don't think you can use VB in transformations


if upgrading is not an option... your other option is to use a repeater with this in the path: ..

It would refer fetch the parent document

User avatar
Member
Member
lwhittemore-emh - 11/18/2011 1:22:49 PM
   
RE:Document Type Parent
I think that is my issue. Our version is 5.5.3999 which I assumed was greater than R2 but I think it is not.