How to show/hide webpart on specific document within one template

Technical support leader

Juraj Ondrus asked on November 6, 2009 02:37

How to show/hide webpart on specific document within one template

Correct Answer

Juraj Ondrus answered on November 6, 2009 02:37

When you’d like to display webpart within one page template only on specific document, it’s possible to take advantage of ‘Edit Value’ button in webpart properties. You can add following macro expression for ‘Visibility’ property:

{%cmscontext.currentdocument.documentname|(equals)Home|(identity)GlobalAdministrator%}

Please note, you can place whatever document name instead of "Home". This will enforce that webpart will be shown on document with that name. You can find more about macros in our Developer's guide.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Chetan Sharma answered on April 9, 2016 12:55 (last edited on April 9, 2016 12:56)

Hi Juaraj,

    We can also accomplish based on Show for Page Types field. Let's say that you have multiple page types sharing a page template and you want to show it specifically for "PT - Home". You can make use of the above property and check the page types you want the webpart to render on.

p.s - we use this approach very often.

Thanks,
Chetan
0 votesVote for this answer Mark as a Correct answer

Rananjay Singh answered on September 11, 2017 15:40 (last edited on December 10, 2019 02:31)

You can use below code it's working for me {% if(CurrentPageInfo.DocumentNamePath == "/Search-Physician/Physician-List" ) { return true; } else { return false; } |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

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