API
Version 7.x > API > Modifying Entered Path in Code-Behind View modes: 
User avatar
Member
Member
eric.rovtar - 7/22/2013 3:22:01 PM
   
Modifying Entered Path in Code-Behind
Hi!

I have a Custom Macro that is rendered based on the path parameter the user passes to it. This path defaults to the pages below the current document ("./%").

The second most common path entered would be "../%".

In my C# code, I need to also access the root document of both these paths, "." and ".." respectively. Is there a method in the API that would allow me to manipulate the path passed into my method in a way to do that?

The way I'm currently doing it is a conditional (if (path == "./%") then parent = ".")).

I'm just wondering if there's a better way to do it. I could also remove "/%" from the end of the string, but wasn't sure if anyone else had some suggestions.

Thanks!

-Eric

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/22/2013 11:34:26 PM
   
RE:Modifying Entered Path in Code-Behind
I don't think many people know or use this feature enough. In the path enter something like
/{0}/{1}/%
This will get all the documents from second level of the current node. For instance you have two nodes like so:

/About/Contact/Office 1
/News/Current/News Item One

It will always get the documents below Contact and Current.

One other thing you can do us use the macro
{% CurrentDocument.Parent.NodeAliasPath %}
As the code shows, it will get the parent's alias path of the current document.

I'm not positive this will resolve the current issue you are having but they have helped me tremendously. Good luck