Skip to main content
Hi - 

I have a VF page which I have added on the Account detail Page . I want to display this page only in Classic and hide the page completely in Lightning record detail page .To achieve this I added a rendering tag (rendered="{!!CONTAINS($CurrentPage.URL, 'lightning.force.com')}") which check the URL and hide the page from Lighting and show only in Classic .Though the page is not displaying in lightning,but  it leaves a white space behind . Could you please help me on how to get rid of this whitespace?

Code :

<apex:page standardController="Account" lightningStylesheets="false" rendered="{!!CONTAINS($CurrentPage.URL, 'lightning.force.com')}" >

    <apex:outputField value="{!Account.name}"/>

    <!-- Adding Detailed section using OutputField -->  

    <apex:pageBlock title="Account Details">

    <apex:pageBlockSection >        

    <!--apex:detail relatedList="false"/ -->

            <apex:outputField value="{!Account.name}"/>

            <apex:outputField Value="{!Account.phone}"/>

            <apex:OutputField value="{!Account.Country__c}" />

            <apex:outputField Value="{!Account.State__c}" />

            <apex:outputField Value="{!Account.AnnualRevenue}" />

            {!Account.AnnualRevenue}    

    </apex:pageBlockSection>    

    </apex:pageBlock>

    

 <!-- Adding Releated List using PageBlockTable -->     

    <apex:pageBlock title="Associated Contacts" >       

         <apex:pageBlockTable value="{!Account.contacts}" var="con">      

         <apex:column value="{!con.Name}"/>

         <apex:Column value="{!con.Title}" />        

    </apex:pageBlockTable>    

    </apex:pageBlock>

    

    <apex:pageBlock title="Associated Opportunities">

    <apex:pageBlockTable value="{!Account.opportunities}" var="Oppty">

        <apex:column value="{!Oppty.name}"/>

        <apex:column value="{!Oppty.Type}"/>  

        <apex:column value="{!Oppty.stagename}"/>        

    </apex:pageBlockTable>

        

    </apex:pageBlock>   

 <!-- Adding Releated List using relatedList component -->     

<apex:relatedList list="Contacts"/> 

<apex:relatedList list="Opportunities" pageSize="5"/>

    <!-- /apex:outputPanel -->  

</apex:page>

This is how it looks on the lightning Account record page:

How to show VF page in Classic and hide in Lightning

Please help me on this 

Thanks !
2 answers
  1. May 22, 2024, 10:51 AM

    Hi @Priya Ranjan, after unchecking the "Available for Lightning Experience, Lightning Communities, and the mobile app" checkbox, the vf page still appears in the Lightning record page along with the classic page. 

0/9000