2

I would like to create a VisualForce page that shows on a Contact record, however, I only want it to show while the user is in Classic mode. I have tried using $User.UIThemeDisplayed to render the wrapping apex:outputPanel depending on if the User is in Classic or Lightning. However, while in Lightning this results in a massive block of whitespace where I would like for the space to not even be allotted to the page.

UPDATE: I tried to simplify my page but I realize that the previous example actually behaves exactly how I want it to. What I am also doing in my page is using Lightning Out to display a custom Lightning component for classic. My hope is that this VisualForce page only shows in classic and that I can use the custom Lightning component as it's own tab in the Lightning experience.

<apex:page standardController="Contact" standardStylesheets="false">
  <apex:outputPanel rendered="{!$User.UIThemeDisplayed == 'Theme3' }">
      <apex:stylesheet value="{!URLFOR($Resource.SLDS202, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
      <apex:includeScript value="/lightning/lightning.out.js" />
      <div id="lightning" />
      <script>
          var contactId = "{!Contact.Id}";
          $Lightning.use("c:MyApp", function() {
              $Lightning.createComponent("c:RelationshipWidget",
              { recordId : contactId},
              "lightning",
              function(cmp) {});
          });
      </script>
  </apex:outputPanel>
</apex:page>

2 Answers 2

1

You can also uncheck the value "visualforce page available for Lightning and mobile experience" in setup->visualforce pages

you wont have to detect theme, add to the classic layout: it will show in classic and will not show in lightning

0

There is currently a Known Issue: Spring '17 Visualforce Pages appearing in Lightning when not flagged to do so.

Unchecking the "Available for Lightning Experience, Lightning Communities, and the mobile app" doesn't always work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .