Bug reports
Version 2.x > Bug reports > Path resolve View modes: 
User avatar
Member
Member
mike@xcomms.ie - 5/2/2007 1:37:13 PM
   
Path resolve
Hi,

I had a problem with Path resolution not working properly for parent documents. Tech support confirmed this as a bug, so I thought I'd just list it here for reference, including a quick work around:

I was trying to use the CMSViewer to display the document name of a parent item.

If i use the Path /%, all documents are displayed, so the transformation code itself is working. I can also manually determine which document I want to display, e.g. with /Village-Homes But I cannot seem to display documents using a relative path such as .. or../ or ../% as suggested in the documentation. Tech support confirmed that this a bug that is being fixed at the moment.

In the meantime, I wrote a dirty little function that provides a work around. Rather than setting the Path to '..', I determine the parent's path with the following function:
    public string parentPath()
{
// store the current page's path in a string
string strCurrentPath = CMSCurrentPage.Path.ToString();
// shave off the last path node of the current page's path:
return strCurrentPath.Substring(0,strCurrentPath.LastIndexOf('/'));
}

The returned string can then be used to set the path for a control.

Hope this helps someone running their head against a similar wall...

Rgds,
Mike

User avatar
Member
Member
mike@xcomms.ie - 5/2/2007 1:46:06 PM
   
RE:Path resolve
The most important bit I forgot of course - CMSCurrentPage is taken from a CMSBreadcrumb control on the page.

User avatar
Member
Member
mike@xcomms.ie - 5/3/2007 11:44:40 AM
   
RE:Path resolve
And an answer from Techsupport came back with the much cleaner (and prefered) solution of using the TreePathUtils - so here as usual the copied reply for reference:

''I see you are using the ASPX code for your Viewer, you can resolve the path manually in the codebehind to be able to workaround the issue. You can use two different approaches:

1) Work directly with current document path and get the parent path
CMSViewer1.Path = TreePathUtils.GetParentPath(CMSContext.CurrentPageInfo.NodeAliasPath);

2) Use the built-in procedure to resolve the parent path for you
CMSViewer1.Path = CMSContext.ResolveCurrentPath('..');

Please note that this code should run before the CMSViewer Init event for proper configuration of the control in the time it loads the data so you should run it as soon as possible (for example in page PreInit). Otherwise you will need to use the CMSViewer.ReloadData method to reload the control with new parameters.''

Note that I substituted the double quotes in the code with ' characters to avoid encoding in this forum.

User avatar
Kentico Developer
Kentico Developer
jaroslavk - 5/9/2007 2:16:24 PM
   
RE:Path resolve
Hello,

just want you to ensure that this bug will be fixed in next version 2.1e which will be released this friday.

Best Regards,
Jaroslav Kordula