Sometimes we need to hide header and sidebar of a Visualforce page or Standard layout. So here are some ways to hide header and sidebar for Salesforce Visualforce page and Standard layout.
Generally in Visualforce Page we use sidebar="false" to hide sidebar. To hide header and chat widget we use header="false" and showChat="false" respectively.
Hide Header and Sidebar from Visualforce Page with specifying header="false" and sidebar="false".
Hide Header and Sidebar from Visualforce Page or Standard Layout by adding isdtp parameter in the URL. The main purpose of isdtp can be used to hide Salesforce header and sidebar on Standard Pages.
vw – The Visualforce page will be rendered without header and sidebar, supports aloha theme, allows chatter.
lt – leaves off SF formatting, page header, sidebar, tabs and section header.
nv – The page will be rendered without the tabs and sidebar, and will accommodate all the buttons in a list view.
mn – Retains Old Salesforce Styling, hides page header(tabs) and sidebar.
PageReference pgref = new PageReference('/apex/pagename?recordId&isdtp=vw);
Hide Sidebar from Standard layout.
Go to – Setup || Customize || User Interface – checked the check box “Enable Collapsible Section”. After that you can show or hide sidebar in Standard layout.
Salesforce provides 5 different kind of Icons (Standart, Custom, Utility, Doctype, Action) which can be used in Lightning component and Visualforce page. Find SLDS Icons here.
Example:
Instead of uploading the Lightning Design System as a static resource, we can include apex:slds inside the head tag of Visualforce page to use Lightning Design System stylesheets in the page.
Here I’ve a custom “Student__c” object. There is a validation rule on “Date_of_Birth__c” field, that Date of Birth cannot be greater than today. And I’m using a visualforce page to insert the data in “Student__c” object. So, I need to show the validation rule error message in visualforce page.
Validation Rule:
Below is my controller which gave the solution for displaying validation error message on visualforce page.
Controller:
public with sharing class StudentExt {
public Student__c student{get;set;}
public StudentExt(ApexPages.StandardController controller) {
student = (Student__c)controller.getRecord();
}
public Pagereference saveStudent() {
try {
Upsert student;
return new Pagereference('/' + student.Id);
}
catch(DMLException de) {
Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, de.getDmlMessage(0)));
return NULL;
}
catch(Exception e) {
Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, e.getMessage()));
return NULL;
}
}
}