ASPX templates
Version 5.x > ASPX templates > TreeProvider selectsinglenode question View modes: 
User avatar
Member
Member
vino-fsm - 1/13/2010 7:34:18 PM
   
TreeProvider selectsinglenode question
I have this line of code but it doesn't return any of the article i have in the site.

TreeNode node = tp.SelectSingleNode(CMSContext.CurrentSiteName, "/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "CMS.Article", "", "", -1, true);

Seems to always return null. Any ideas why?

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 1/14/2010 6:59:25 AM
   
RE:TreeProvider selectsinglenode question
Hello,

I've tried this code on sample CorporateSite and it works well there. Could you please debug the code to see which values are used as site name and culture and double check there exists any document of type 'CMS.Article' in given culture on site with given name?

Best Regards,

Martin Dobsicek

User avatar
Member
Member
vino-fsm - 1/14/2010 7:40:17 PM
   
RE:TreeProvider selectsinglenode question
Hi,

Here's my output

CMSContext.CurrentSiteID = 2
CMSContext.CurrentDocumentCulture.CultureCode = en-AU

I ran tp.SelectSingleNode(292) and manage to get a node with info below
NodeID = 292
NodeName = Savvy
NodeClassName = CMS.Article
DocumentCulture = en-AU
NodeSiteID = 2

So it seems to works with tp.SelectSingleNode(ID) but not
tp.SelectSingleNode(CMSContext.CurrentSiteName, "/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "CMS.Article", "", "", -1, true);


User avatar
Kentico Developer
Kentico Developer
kentico_martind - 1/15/2010 5:43:15 AM
   
RE:TreeProvider selectsinglenode question
Hello,

Couldy you please try to change last parameter to false? If this won't help, could you please let me know what version of Kentico CMS you use?

Best Regards,

Martin Dobsicek

User avatar
Member
Member
vino-fsm - 1/17/2010 4:58:07 PM
   
RE:TreeProvider selectsinglenode question
Hi,

Im using v5.0.3644. Still returns null with false as last param.

thanks

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 1/20/2010 7:26:54 AM
   
RE:TreeProvider selectsinglenode question
Hello,

this issue is most probably caused by the '%' macro is no longer supported in path in version 5.0 as this character can be used in alias path of document. Please use direct alias path of document instead.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
vino-fsm - 1/20/2010 9:27:34 PM
   
RE:TreeProvider selectsinglenode question
Hi,

You're right, I swapped '%' with an alias path to an article and it returned that specific article. However doesn't that defeats the purpose of the 'where' param if I can't use a wildcard for the Path param?

Also the '%' macro still works with most other functions such as treeProvider.SelectNodes();

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 1/28/2010 3:38:23 AM
   
RE:TreeProvider selectsinglenode question
Hello,

Well, the SelectNodes method is intended for acquiring multiple documents so the '%' macro is useful there, but it is not necessary in SelectSingleNode method as this method always returns one node only anyway.

Best Regards,

Martin Dobsicek