Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > DocumentsOnPath and NodeAliasPath View modes: 
User avatar
Member
Member
mosgath - 2/28/2013 2:31:20 PM
   
DocumentsOnPath and NodeAliasPath
I ran into an issue with DocumentsOnPath property of the CurrentDocument. We have a content structure similar to below:
/
/Folder1
/Folder1/Business
/Folder1/Business/Core
/Folder1/Business/Core-Special

If I use Current.DocumentsOnPath on the "/Folder1/Business/Core-Special" page, I get an additional item. Looking at the contents of this array, it is pulling back "/Folder1/Business/Core" as being on the path of "/Folder1/Business/Core-Special" even though it is not on the path. The are two separate documents within the same parent.

Looking at the debug SQL, this is due to the link clause being used to retrieve this list.
SELECT * FROM View_CMS_Tree_Joined WHERE ((NodeSiteID = 3) AND 
(DocumentCulture = N'en-US'))
AND ('/Folder1/Business/Core-Special' LIKE NodeAliasPath + '%') ORDER BY NodeLevel

I have a worked around this by updating the NodeAliasPath of "/Folder1/Business/Core" to something like "/Folder1/Business/Core1", but having our Content Editors watch for this is not ideal.


User avatar
Member
Member
mosgath - 2/28/2013 2:31:53 PM
   
RE:DocumentsOnPath and NodeAliasPath
I am on version 7.0.3.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/2/2013 11:55:24 AM
   
RE:DocumentsOnPath and NodeAliasPath
Hi,

I think I am missing something here. What is the relation between Core and Core-Special document? What do you mean by "link"?
Are you able to reproduce this issue on the latest hotfix?

I have tried few things but it seems to be working fine on my end (7.0.23)

Best regards,
Juraj Ondrus

User avatar
Member
Member
mosgath - 3/5/2013 7:25:48 AM
   
RE:DocumentsOnPath and NodeAliasPath
The only relation between Core and Core-Special is that they are under the same parent.

Sorry "Link clause" was a typo. It was supposed to be "Like clause".

Since "/Folder1/Business/Core-Special" is like "/Folder1/Business/Core%", it was returning the core in the list of documents on the path. I also found that adding an "_" for the Node Alias of Core didn't help since "/Folder1/Business/Core-Special" is like "/Folder1/Business/Core_%" due to "_" being a special character in SQL Syntax representing any single character.

We have not applied the latest hot fix yet.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/5/2013 6:39:39 PM
   
RE:DocumentsOnPath and NodeAliasPath
Hi,

I am still unable to reproduce the issue. So, could you please apply the latest hotfix so we can exclude already known and fixed bugs? If it won't help, please, describe me exact steps how to reproduce the issue.

Thank you.

Best regards,
Juraj Ondrus

User avatar
Member
Member
mosgath - 3/20/2013 3:47:34 PM
   
RE:DocumentsOnPath and NodeAliasPath
I just got updated to 7.0.24. I am still able to reproduce this.

Here is my docoument alias tree:

{Root}
-Folder1 (1 level)
--Business (2 levels)
---Core (3 levels)
---Core-Special (3 levels)
--Business-Special (2 levels)

Here is the code I am using for a Static Html WebPart on my page.
<a href="~{%if (CurrentDocument.DocumentsOnPath.Count>2,
CurrentDocument.DocumentsOnPath[CurrentDocument.DocumentsOnPath.Count-2].NodeAliasPath,
CurrentDocument.DocumentsOnPath[1].NodeAliasPath)
%}
</a>

If viewed on the Core-Special page, the static generated is
<a href="/Folder1/Business/Core.aspx">
Core
</a>

It should be
<a href="/Folder1/Business.aspx">
Business
</a>

I know for this case I could use the Parent instead of walking the DocumentsOnPath collection, but in some cases, I don't pull the parent, I pull a document from a different level, but I can't guarantee that the DocumentsOnPath is accurate due to this issue.

User avatar
Member
Member
mosgath - 3/20/2013 3:53:36 PM
   
RE:DocumentsOnPath and NodeAliasPath
1. Add document named "Folder1" to root with blank template.
2. Clone template as ad-hoc.
3. Add static html web part. Set Text to:
<a href="~{%if (CurrentDocument.DocumentsOnPath.Count>2,
CurrentDocument.DocumentsOnPath[CurrentDocument.DocumentsOnPath.Count-2].NodeAliasPath,
CurrentDocument.DocumentsOnPath[1].NodeAliasPath)
%}
</a>

4. Save as template.
5. Add document named "Business" under "Folder1". Inherit parent's template.
6. Add document named "Core" under "Business". Inherit parent's template.
7. Add document named "Core-Special" under "Business". Inherit parent's template.
8. Add document named "Business-Special" under "Folder1". Inherit parent's template.
9. View "Core-Special" page.

It will say "Core" instead of "Business" and link to the Core.aspx page instead of Business.aspx page.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/25/2013 10:36:25 AM
   
RE:DocumentsOnPath and NodeAliasPath
Hi,

I just noticed, the macro is syntactically wrong.

There is no construction like "if (xyz, xyz1, xy2)" which you used.

Have you tried using the correct K# syntax?

Best regards,
Juraj Ondrus

User avatar
Member
Member
mosgath - 3/25/2013 11:44:56 AM
   
RE:DocumentsOnPath and NodeAliasPath
I changed the syntax to the "if else" syntax. No Change. I use the if(,,) syntax several places and it works just fine.

As I stated in my original report of this error, this is due to the SQL that is being executed to populate the DocumentsOnPath. With SQL Debug Trace enabled I get the following in the context of CMSPortalManager.CMSPortalManager_Init:
(cms.document.selectdocuments)
SELECT * FROM View_CMS_Tree_Joined WHERE ((NodeSiteID = 3) AND (DocumentCulture = N'en-US')) AND ('/Folder1/Business/Core-Special' LIKE NodeAliasPath + '%') ORDER BY NodeLevel

For '/Folder1/Business/Core-Special/' I would expect 4 documents to be on the path, but it returns 5.

The DocumentsOnPath return the following documents:

{Root}
-Folder1
--Business
---Core
---Core-Special

It should only return

{Root}
-Folder1
--Business
---Core-Special

The document with an alias path of '/Folder1/Business/Core' is not on the path of the document with an alias path of '/Folder1/Business/Core-Special'.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/26/2013 12:35:59 PM
   
RE:DocumentsOnPath and NodeAliasPath
Hi,

Thank you for the details, much appreciated! I was investigating it as well and at around the same time I notced the SQL query is not returning correct number of records too - I have forwarded it to our developers. It seems to be a mistake in the WHERE condition. I am sorry for this inconvenience.

Best regards,
Juraj Ondrus