Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Need to get a document ID at a specific node level. View modes: 
User avatar
Member
Member
nathan.vaughn-imaginuity - 1/5/2012 2:40:15 PM
   
Need to get a document ID at a specific node level.
I've searched a ton & attempted many things before resorting to posting a request for help. I'm an ASP.net / C# novice but I know general programming and Kentico.

My situation:
I have a template that may be accessed from different node levels. News Articles related to these pages are in a separate area of the site. I would like to be able to get the documentID of node level 3 no matter from where the template is accessed.

e.g. Both of these pages use the same template
http://site.com/stores/
http://site.com/stores/management/john-doe

related news items are here:
http://site.com/news

In the WHERE clause of the repeater on the template, is there a way to accomplish this? I need to specificy something like WHERE StoreID IN (SELECT newsID WHERE StoreID = StoreID)

Is there something like "WHERE %/{0}/{1}/documentID%" <-- That's the only part I need help with, if this is even possible.

Sorry to surrender and ask for help but I've been banging my head against this for a while. At least I've learned some other stuff along the way though.

User avatar
Member
Member
nathan.vaughn-imaginuity - 1/5/2012 2:47:13 PM
   
RE:Need to get a document ID at a specific node level.
I perhaps could have worded things a little better.

Here's a re-wording of my issue:
- I'm trying to pull in related articles from a separate area of the site.
- I'm trying to pull them into a page that uses a template that can be accessed from different node levels.
- I'm trying to find out if there's a way to put a macro in the WHERE clause of the repeater on this template, so that it doesn't matter from which node level you have accessed the page.

All of this is easy enough to do with other types of content in the node tree by simply using the Content Path setting in the web part. This content I'm trying to pull in is in a separate area, and has articles with one-to-many relationships so this must be handled in there WHERE clause instead I believe.

User avatar
Member
Member
acasal-imediainc - 6/21/2012 4:16:13 PM
   
RE:Need to get a document ID at a specific node level.
If it helps anyone out, here's one solution (if you're putting it in a place that's not a WHERE using K# )

{% if (nodelevel==3) { return Parent.Parent.DocumentName; } else { return Parent.DocumentName; } %}

User avatar
Member
Member
nathan.vaughn-imaginuity - 1/5/2012 3:17:45 PM
   
RE:Need to get a document ID at a specific node level.
Another solution I've thought of would be to create a very similar template with this particular web part configured different. It would simply need to get the documentID of its parent's parent. To my knowledge, this macro does not exist.

"WHERE {%cmscontext.currentdocumentparent.documentid%}" <-- that works for the parent, but I need the parent's parent.

Without going into the code behind (which I may not be able to comprehend anyway) I tried to get the parent's parent with no luck.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/6/2012 2:03:27 AM
   
RE:Need to get a document ID at a specific node level.
Hello,

You should be able to use the following where condition, if you are using Kentico 6.0:

documentid = {% CurrentDocument.Parent.Parent.DocumentID %}

Best regards,
Boris Pocatko

User avatar
Member
Member
nathan.vaughn-imaginuity - 1/6/2012 9:10:18 AM
   
RE:Need to get a document ID at a specific node level.
Fantastic Boris, thank you.

User avatar
Member
Member
PeterPC - 4/24/2012 8:39:00 AM
   
RE:Need to get a document ID at a specific node level.
Hi Boris,

Is there an equivalent to {% CurrentDocument.Parent.Parent.DocumentID #%} in Kentico 5.5?

I'm looking to get a field value from a parent's parent without creating a custom macro in 5.5. Is it possible?

Thanks
Pete

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 4/29/2012 4:28:08 AM
   
RE:Need to get a document ID at a specific node level.
Hello,

Regrettably, you can get only two levels higher in 5.5 without a custom macro:

{%cmscontext.currentdocumentparent.nodeparentid%}

I am not sure if this is sufficient for you, but I would recommend to use a custom macro or to upgrade as you are missing out on new features and 7.0 is right around the corner.

Best regards,
Boris Pocatko

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 11/18/2012 6:34:08 PM
   
RE:Need to get a document ID at a specific node level.
HI Boris,

I am using kentico 7. In one of my custom fields in the document type I am giving a default value as below:
{%cmscontext.currentdocumentparent.DocumentID%}

But it doesn't resolve any value.

can I use this in default value field in document types?

Thanks
Gitesh Shah

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/25/2012 7:12:58 PM
   
RE:Need to get a document ID at a specific node level.
Hello,

Could you please post a screenshot of the macro debug how this expression is resolved?

Best regards,
Boris Pocatko