1

I need to set the showheader property in visualforce page to true or false based on user profile. For all internal salesforce users the showheader property should be set to true and for all external/portal users the showheader should be set to false.

<apex:page standardController="Contact" showHeader="true">
    <apex:detail relatedList="true" inlineedit="TRUE" />
</apex:page>
  • @Eystornt Using rendered attribute within apex detail section, can we set showheader property to true or false? For all profiles i need to display the same detail but only i need to change the showheader attribute. – Ean Oct 26 '16 at 12:10
  • Ha, my bad. I read that question too quickly ! Wait a second – Simon Govaert Oct 26 '16 at 12:10
  • @Eystornt Ok Sure. – Ean Oct 26 '16 at 12:12
  • Apparently you can use the attribute rendered on the <apex:page> tag. So you can do something like <apex:page standardController="Contact" showHeader="true" rendered="{!$Profile.Name == 'SomeProfileName'}"> – Simon Govaert Oct 26 '16 at 12:13
  • From where users navigate to the page, can you write some condition over there? – Raul Oct 26 '16 at 12:26
2

The showHeader attribute supports normal Visualforce expressions so you can reference Visuaforce globals like $Profile or controller boolean properties.

For example, this will only show the header for SA users:

<apex:page showHeader="{! $Profile.Name == 'System Administrator' }">
Page content
</apex:page>

No need for 2 pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.