Display Document Type Field Only on a specified Document Name

Dcode warner asked on May 11, 2017 00:53

How do I write a Marco (inside the document type proprieties's visible condition) to show the field only on a specified document name:

Example code CurrentDocument.DocumentName == "page"

Correct Answer

Brenden Kehren answered on May 12, 2017 00:03

Like I said in my reply, this would be the alternative:

"Ok I stand corrected EditedObject is not available as a macro in v7. You can access it via code using CMSContext.EditedObject so maybe make a custom macro method."

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on May 11, 2017 01:31

Use the EditedObject vs. CurrentDocument context. CurrentDocument is only available on the edit or design tabs or live site. Use EditedObject in on the form tab.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on May 11, 2017 16:16 (last edited on December 10, 2019 02:30)

Does not work for me. Is EditedObject the DocumentName of the page? I've also tried: {% EditedObject.NodeAliasPath.Contains("/page") |(identity)GlobalAdministrator%} and EditedObject.cmscontext.currentdocument.documentname|(equals)pagename

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 11, 2017 21:58 (last edited on December 10, 2019 02:30)

If you're doing it for an INSERT or a NEW page it won't work properly because there is no page or document name YET. This will only work with a page you've already created. For a new page your best bet is to use a class name, site name, or node alias path.

This is the correct syntax in the visibility field
{% EditedObject.DocumentName == "my name" |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on May 11, 2017 22:43 (last edited on December 10, 2019 02:30)

Yes This is for a page already created. More specifically, we created two blogs on the same site. So we're trying to remove a field (we created), from showing on the second blog in the cmsdesk. The first blog remains as is but we don't need that field for the other blog.

We attempted {% EditedObject.DocumentName == "Blog2" |(identity)GlobalAdministrator%} and other methods and variations with no luck so far

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 11, 2017 22:48

Then use EditedObject.NodeAliasPath.Contains("/Blog-2")

What version is this? Guessing 7 based on the "cmsdesk" reference. Should still work I believe.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on May 11, 2017 22:57

yes. This is K7. Unfortunately it doesn't work. Would it matter if the Alias path contains brackets? /History-(1) I don't think that would matter.

If it helps. This works. So if only it can be narrowed down to the blog name: Visible condition: CurrentSite.SiteName == "xxx.com"

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 11, 2017 23:40 (last edited on May 11, 2017 23:46)

Ok I stand corrected EditedObject is not available as a macro in v7. You can access it via code using CMSContext.EditedObject so maybe make a custom macro method. CurrentDocument does not exist but you can get a NodeID or a DocumentID via the URL parameter. Might check with Kentico Support to see if there is a macro to get the document properties while in the form tab in v7.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on May 12, 2017 00:01

Support says it's not supported by K7 like you said. :( Is there an alternative method you can suggest - so that we achieve the same result?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.