[SalesForce] How to pass a variable to a custom label

I have this custom label in a Visual Force page: {!$Label.fb_contact_cs_title}

I want to first have an in-page conditional statement. Then I want to put that variable into the custom label.

{! if case.origin = 1, variable = 10; if case.origin = 2, variable = 20 }
{!$Label.fb_contact + variable}

Best Answer

You can declare a variable and set the conditional value like this:

<!-- Declare a variable and set it's value. If it's not 10 or 20 it'll be 0 - assumption -->
<apex:variable value="{!IF(case.origin == 1, '10', IF(case.origin == 20, '20', '0'))}" var="myVar" /> 

Then you can use it anywhere you like, just like a normal merge field:

<apex:outputText value="{!myVar}" />

In your case just concatenate it to your label.