Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > urlrewrite and linked documents issue View modes: 
User avatar
Member
Member
Ark_IT - 4/6/2010 1:21:20 PM
   
urlrewrite and linked documents issue
when you have document with DocumentUrlPath set and some links to it in different catalogue branch - some strange behavior can appear. Especially when other catalogue nodes are of some different structure.
Forexample - when we have doc with docurlpath /mydroduct (www.mysite.com/myproduct) and some link-docs to it, kentico engine use this query to determine path

(SELECT TOP 1 * FROM View_PageInfo WHERE ((NodeSiteID = 1) AND (DocumentUrlPath = N'/myproduct') AND (DocumentUrlPath <> NodeAliasPath))) UNION ALL (SELECT * FROM View_PageInfo WHERE ((NodeSiteID = 1) AND (NodeAliasPath = N'/myproduct') AND (DocumentCulture = N'en-EN')))

without "TOP 1" it rerurn all of aliasnodes and the main node.
in result with "TOP 1" there can be ANY of alias nodes with this documenturlpath - its the way TSQL top-engine works. It return the most "quickly-returnable" item :)

so nodealiaspath - (the thing we want to know for future) - can be any of nodealiaspath

then if you have breadcrumbs (for example) it shows you the way to your random alias ))

For my project i fixed it by adding "and (NodeLinkedNodeID is NULL)" to query.text

now it looks like this:

(SELECT TOP 1 * FROM View_PageInfo WHERE ((NodeSiteID = 1) and (NodeLinkedNodeID is NULL) AND (DocumentUrlPath = N'/myproduct') AND (DocumentUrlPath <> NodeAliasPath))) UNION ALL (SELECT * FROM View_PageInfo WHERE ((NodeSiteID = 1) and (NodeLinkedNodeID is NULL) AND (NodeAliasPath = N'/myproduct') AND (DocumentCulture = N'en-EN')))

it works)

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/8/2010 7:18:12 AM
   
RE:urlrewrite and linked documents issue
Hello,


I am not sure where BreadCrumbs use the query for View_PageInfo. It should use the document type Select query. Could you please advise me where the mentioned query gets used?

Thank you in advance.


Best regards,
Helena Grulichova

User avatar
Member
Member
Ark_IT - 4/8/2010 9:25:03 AM
   
RE:urlrewrite and linked documents issue
query with "Select from View_PageInfo..." has no name and starts in this context:

PageInfoProvider.GetDataForPageInfo
PageInfoProvider.GetPageInfo
PageInfoProvider.GetDataForPageInfoForUrl
PageInfoProvider.GetPageInfo
URLRewriter.RewriteUrl
Global.RewriteUrl
Global.Application_AuthorizeRequest

its always 1-st or 2-nd query (not counting procedures with setting key retr)

BreadCrumbs doesnt use this query, but in case this query gives incorrect results - breadcrumbs shows the way one of the doc, linked to this doc. And so other webparts on the page does.
Breadcrumbs is just for example - it showed me the way to solve issue ))

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/9/2010 6:43:26 AM
   
RE:urlrewrite and linked documents issue
Hello,


I am not sure where I can see the incorrect behavior. If I link one document on several parts of content tree and use Breadcrumbs on master page then Breadcrumbs always show the path of original document.

Could you please advice me how to reproduce the incorrect behavior? Thank you.


Best regards,
Helena Grulichova

User avatar
Member
Member
Ark_IT - 4/12/2010 3:07:24 AM
   
RE:urlrewrite and linked documents issue
1. We use extensionless docs and DocumentUrlPath set, so docs address is like http://www.mysite.com/mydoc

in CMS_Tree we have -
NodeID - 558143
NaodeAliasPath - /Catalogue/n13717/n13727/tn_1000024607
NodeName - mydoc
NodeLinkedNodeID - NULL
(and so on)

in CMS_Document we have
DocumentID - 128240
DocumentName - mydoc
DocumentNamePath - /Catalogue/n13717/n13727/tn_1000024607
DocumentUrlPath - /mydoc
DocumentNodeID - 558143


2. Set several nodealiases - they all have the same NodeName, but different NodeAliasPath and ids (of cause)
my example of NodeAliasPaths:
/Catalogue/n13717/n13738/tn_1000024607
/Classifiers/t_1/n10607/n10608/tn_1000024607
/Classifiers/t_1/n10625/n10634/tn_1000024607
/Classifiers/t_1/n10680/tn_1000024607
/Classifiers/t_2/n10821/n10823/tn_1000024607
/Classifiers/t_5/n13147/n13148/n13150/tn_1000024607
/Classifiers/t_5/n13147/n13159/tn_1000024607

All aliases have NodeLinkedNodeID - 558143

3. Now this -
when i try to access document on site - http://www.mysite.com/mydoc
it may return any of alias, but must return the main doc!

as i said - query "SELECT TOP 1 * FROM View_PageInfo...." return "the fastest-returnable" item and its not always the main doc! - its top-engine of sql.

so i added condition "and (NodeLinkedNodeID is NULL)" and its ok now.




User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/12/2010 9:19:33 AM
   
RE:urlrewrite and linked documents issue
Hi,

thank you for the reply and sharing the information on how you resolved the issue with us.

In my opinion, you may also try to enable setting "Redirect document aliases to main URL" in SiteManager / Settings / URLs and SEO

Context help says:
If enabled, the document always has only one valid URL and other aliases are redirected to this main URL, for SEO purposes.


Best Regards,
Zdenek C.

User avatar
Member
Member
Ark_IT - 4/15/2010 3:05:37 AM
   
RE:urlrewrite and linked documents issue
Hello, Zdenekc!
This setting doesnt help!
Checked it in both global and mysite settings ))
Restarted
same thing - "random" alias

so added back the code like this:

/*-------------------------*/
static void BeforeExecuteQuery(CMS.SettingsProvider.QueryParameters query, CMS.IDataConnectionLibrary.IDataConnection conn)
{

if (query.Text.Contains("(SELECT TOP 1 * FROM View_PageInfo"))
{ query.Text = query.Text.Replace("(NodeSiteID = 1) ", "(NodeSiteID = 1) AND (NodeLinkedNodeID is NULL) "); }

.......

/*-------------------------*/
that works

User avatar
Member
Member
Ark_IT - 4/28/2010 12:58:48 AM
   
RE:urlrewrite and linked documents issue
Guess you added it to hotfix 5.0.16 )
Thank you

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/30/2010 10:56:34 AM
   
RE:urlrewrite and linked documents issue
Hello,
You're welcome.

Following description can be found in the 5.0.16. fixes list:

- Linked documents were not processed correctly during multiple publish and archive operations.

- Linked documents with specified URL path property were incorrectly displayed instead of the original document.


Best regards,
Zdenek C.