Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Help with path macro View modes: 
User avatar
Member
Member
lwhittemore-emh - 11/28/2012 1:42:12 PM
   
Help with path macro
I have a repeater that i want to display on a page. I have two document types that show in this repeater (cms.menuitem; inland.relatedlink). What I would like to have happen is that if the current page has documents below it in the tree (of either of these two types) to show them in the repeater. However, if there are none I want to show the documents at the current level.

User avatar
Member
Member
lwhittemore-emh - 11/28/2012 3:22:52 PM
   
RE:Help with path macro
{% TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); DataSet documents = tree.SelectNodes(CMSContext.CurrentSiteName, "./%", "en-us", false, "CMS.MenuItem");   if (DataHelper.DataSourceIsEmpty(documents)) {"../%"} else {"./%"} %}


This is what I am trying to make work.

User avatar
Kentico Support
Kentico Support
kentico_janh - 11/29/2012 8:23:32 AM
   
RE:Help with path macro
Hello Lawrence,

You can use following macro as the Path property:

{%
children = CurrentDocument.Children;
hasChild = false;
foreach(child in children) {
if (child.NodeClass.CodeName == "CMS.MenuItem" || child.NodeClass.CodeName == "inland.relatedlink")
hasChild = true;
}
if (hasChild) {
return "./%";
}
else {
return "../%";
}
%}


Best regards,
Jan Hermann