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
Jonathan SpinkJonathan Spink 

Coding link which works for Lightning and Community

I've had to rewrite an Apex Link so it works both in Lightning and inside a Community - but it's clunky as I've had to hard code the community name ('volunteermanagement'):

<apex:outputLink value="/{!pos.account.id}" rendered="{!$User.UIThemeDisplayed == 'Theme4d'}" target="_top">{!pos.account.name}</apex:outputLink>
           
<apex:outputLink value="/volunteermanagement/s/detail/{!pos.account.id}" rendered="{!$User.UIThemeDisplayed != 'Theme4d'}" target="_top">{!pos.account.name}</apex:outputLink>

Can you advise me on something which only requires one statement?

Many thanks

 
Best Answer chosen by Jonathan Spink
AnudeepAnudeep (Salesforce Developers) 
Hi Jonathan, 

I am afraid there isn't any other way

I looked at some samples in the documentation and I see the same approach
 
<apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme3' }">
    <apex:outputText value="This is Salesforce Classic."/>
    <apex:outputText value="These are multiple components wrapped by an outputPanel."/>
</apex:outputPanel>
<apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme4d' }">
    <apex:outputText value="Everything is simpler in Lightning Experience."/>
</apex:outputPanel>

 

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Jonathan, 

I am afraid there isn't any other way

I looked at some samples in the documentation and I see the same approach
 
<apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme3' }">
    <apex:outputText value="This is Salesforce Classic."/>
    <apex:outputText value="These are multiple components wrapped by an outputPanel."/>
</apex:outputPanel>
<apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme4d' }">
    <apex:outputText value="Everything is simpler in Lightning Experience."/>
</apex:outputPanel>

 
This was selected as the best answer
Jonathan SpinkJonathan Spink
Thanks for the link! Jonathan
AnudeepAnudeep (Salesforce Developers) 
Appreciate if you can mark the answer as Best if you have found the information I shared helpful. Thanks!