Convert the Path value of a Web Part to a Document Object or Collection of Document Objects

Jay Heavner asked on March 7, 2016 23:33

I have a Repeater Web Part. It's Path value is set as ./SomeChild/%. In my HTML Envelope I would like to use the DocumentName of the parent of the repeated content; basically the DocumentName of SomeChild.

If I use the macro {% Path %} then it renders ./SomeChild/% but it appears to be text and not an Object. Is there another macro that I can pass that output to in order to get a Document Object or, given that there's a wildcard at the end, a collection of Document Objects that I could .First().Parent().DocumentName()?

Basically I want to display the parent Document Name of my repeated content as a header. There has to be an obvious way to do this but I can't figure it out.

Recent Answers

Trevor Fayas answered on March 8, 2016 15:41 (last edited on March 24, 2018 12:15)

The macro "Documents" or "RootDocument" may be where you need to go.

Here's some examples:

{% Documents["./SomeChild/%"].First().DocumentName() |(user)zbynekh|(hash)b945e305084bc2165c181530bb535f3e7d3f89523995b47df463786836d6a504%} {% RootDocument.AllChildren.Where("NodeID=" + QueryString.ID)[0].GetValue("NodeAliasPath") |(user)zbynekh|(hash)84c299c273a55ef5155cb3eb331410378af2b07907cc671e4682ce600ee6fed5%} {% Documents.WithAllData["/MyNode/Path"].DocumentMenuRedirectUrl |(user)zbynekh|(hash)4b68e8ddcec62cb2c8eb1bb1d1eb1406b86c431684d973270e22fb70d5773a51%}

For your particular example, if you can just remove the /% from it, you can do:

{% Documents[Path.Replace("/%","")].DocumentName() |(user)zbynekh|(hash)9c4c09f0ee4a56d6ca9af8d98558cea92a338a0da44d51b1ede3550f584e194f%}

if this helped, please mark as answered

0 votesVote for this answer Mark as a Correct answer

Jay Heavner answered on March 9, 2016 15:20 (last edited on March 24, 2018 12:15)

{% Documents["./SomeChild/%"]|(user)zbynekh|(hash)3e14f4b2c1c423a0c90005a12ba275f1a1e7588390aea36b098879ed5f9fa6f0%} is not valid. What goes inside the brackets needs to be a fully qualified path and the Path property of the web part is not that.

The following expression works for this UC but is not a scalable solution. It would break if the path were {0}/{1}/% or ../% {% docPath = Path.Replace(".", CurrentDocument.NodeAliasPath).Replace("/%", ""); return Documents[docPath].DocumentName |(user)zbynekh|(hash)d29de55584d9aa7f9ba841fbd5e2cafd9cb17d6f9f0cb98675602d0f3701e17a%}

If there were a macro that resolved the web part Path property into a well-formed path then it would work. Imagine something like: {% Path.ResolvePath() |(user)zbynekh|(hash)35eae565f3e7f7ecb322003aa9df577e3faef1bb8fbc5c86a6cd03bec7467686%} that turned ./SomeChild/% into /root/FirstLevel/SecondLevel/CurrentDocument/SomeChild

0 votesVote for this answer Mark as a Correct answer

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