function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to add a VisualForce page with custom controller to a page layout (?)

According to this page to add a visualforce page to a page layout the controller of the visual force page must match the object you want to add it to the page layout of.


What I have seen in reality is like this: if you want to add a VisualForce page to a page layout e.g. of Contacts then the standardcontroller must be set to Contact. At this point the VisualForce page appears in the page layout editor and it can be dragged in. After that you can then change the VisualForce page to have a custom controller and it will continue to work, and will continue to appear in the page layout editor.


This is kind of strange behaviour. Does anyone know if it's possible to add custom controlled VisualForce pages to a page layout in a more orthodox way? Is this a bug? I basically want to be able to write one VisualForce page with custom controller and be able to add it to any page layout I like.

Best Answer chosen by Admin (Salesforce Developers) 



It is a bug, and I wouldn't rely on it being available. You'll need your page to use the StandardController applicable and then create a Controller Extension for each standard controller type you'd like to work with. Then you'll be able to add the page to any number of standard page layouts and they all share the common functionality in the controller extension.


More on controller extensions can be found here: