Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Root document name macro View modes: 
User avatar
Member
Member
lwhittemore-emh - 1/29/2014 5:03:06 PM
   
Root document name macro
I am using version 7 and want to create a right menu that gets the root documents name for the title of the menu

Tree Looks like this
Site Root
- Home
- Getting Started
- - Maps
- - Members
- - Weather

So I don't want the site root but the first document. So when you view getting started or any of it's sub pages you see a menu that has getting started as the title with a list of the menu items below. I can get the menu items using the css list menu web part with a the path set to /{0}/% But I want to add a macro in the before content to get the title.

User avatar
Member
Member
kentico_edwardh - 1/30/2014 1:43:17 PM
   
RE:Root document name macro
Hello,

If you are referring to the Content before field within your web part properties, you can use the following macro to return the parent document name of the specified path - {%Documents["/AliasPath"].Parent.DocumentName%}

Best Regards,
Edward Hillard

User avatar
Member
Member
lwhittemore-emh - 1/30/2014 3:51:13 PM
   
RE:Root document name macro
How do I add a macro to get a relative alias path?

User avatar
Member
Member
lwhittemore-emh - 1/30/2014 5:21:13 PM
   
RE:Root document name macro
If I use a path Macro like this {%Path["{0}"]%} it get's me a node alias path of /Getting-Here for that section. How do I nest the path macro into the context macro and have it resolve?

{%Documents["{&{0}&}"].DocumentName%} this is what I would think but it doesn't work.

User avatar
Certified Developer 13
Certified Developer 13
kentico-jx2tech - 1/30/2014 7:51:24 PM
   
RE:Root document name macro
you can try something like this to add the DocumentName in the Content before...
{% if (CurrentDocument.NodeLevel == 2) 
{ return CurrentDocument.Parent.DocumentName }
else
{ return CurrentDocument.DocumentName } %}

User avatar
Member
Member
lwhittemore-emh - 1/31/2014 6:57:21 AM
   
RE:Root document name macro
Thanks for the reply, but I need to be able to go back to the root from any number of sub pages. So if the node level was 3, 4, 5, 7 or any number to have the side menu so the so the root page title for the menu.

I saw someone post this macro function for the path {% Path["{0}"] %} but it doesn't seem to do anything.

User avatar
Certified Developer 13
Certified Developer 13
kentico-jx2tech - 1/31/2014 8:51:52 AM
   
RE:Root document name macro
try this...
{%Documents["/" + CurrentDocument.NodeAliasPath.Split("/")[1]].DocumentName %}

User avatar
Member
Member
lwhittemore-emh - 1/31/2014 9:06:23 AM
   
RE:Root document name macro
Perfect, Thank You!

User avatar
Member
Member
lwhittemore-emh - 2/6/2014 10:32:16 AM
   
RE:Root document name macro
Oddly enough this doesn't seem to work in firefox. Any idea why?

User avatar
Member
Member
lwhittemore-emh - 2/6/2014 10:49:22 AM
   
RE:Root document name macro
Seems like it's a login issue. not sure what I have done but when I am logged out it doesn't show.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/6/2014 11:21:40 AM
   
RE:Root document name macro
Then you need to unsign your macro. You can do this by adding the # sign like so
{% yourMacroText Goes-HERE %}

User avatar
Member
Member
lwhittemore-emh - 2/6/2014 11:36:44 AM
   
RE:Root document name macro
{%Documents["/" + CurrentDocument.NodeAliasPath.Split("/")[1]].DocumentName%}

This is what it looks like but still doesn't seem to work when logged in.

User avatar
Member
Member
kentico_johnathan - 2/6/2014 2:53:08 PM
   
RE:Root document name macro
The issue is actually with the document permissions, in this case. There are two workarounds:

1) Give public users read access to all documents you want the macro displayed on
2) Add the following key to your web.config file:
 <add key="CMSCheckPermissionsForDocumentCollection" value="false"/>


With either option, the macro seems to work fine for public users on the live site.