I want to show a simple vf page on detail page layout of 10 objects by dragging the vf on to the page layout. Right now, I am writing one vf page for each object as below:


<apex:page StandardController="Account">
    We are on Account Page


<apex:page StandardController="Contact">
    We are on Contact Page

Is there a easy way of doing this, instead of creating new visualforce page for each object?


No. If you want common markup to share across pages for multiple objects, you would move the common markup into a Visualforce Component instead of Visualforce Page.

    <apex:attribute name="sObjectType" type="String" required="true"
        description="Type of SObject for which this component renders" />

    We are on {!sObjectType} Page

Then you'd use this component in your pages.

<apex:page standardController="Account">
    <c:MyComponent sObjectType="Account" />
| improve this answer | |

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.