Search code examples
salesforceapex-codevisualforce

where I have to check variables value or global variable


I have a code

<link rel="canonical" href="{!$Setup.websiteSystemVariables__c.Main_URL__c+$CurrentPage.Name}"/>

I want to check from where

$Setup.websiteSystemVariables__c and

$CurrentPage.Name

values are coming.. I page view source this is visible as a --

<link href="xyz.comhomepageAB" rel="canonical" />

But I want it to be --

I want to add back-slash between URL and page name as i mentioned in URL--

 <link href="xyz.com/homepageAB" rel="canonical" />

I am not able to fix this bug..

I researched on this .. I checked on classes, component but I m not able to solve this.. Please help me out ..

Thanks !!


Solution

  • Full explanation of things you asked for

    $Setup.websiteSystemVariables__c will be a name of custom setting object (Setup->Develop->Custom Settings). You probably have the setting already (otherwise page wouldn't compile). Check if there's at least 1 row there and has something meaningful in the Main_URL__c field. Remember that if you're in developer sandbox (not a full copy one) data is not copied from production so most likely your setting is empty. Looks like it's a hierarchy setting - add the data on "organization" level and you're good to go.

    $CurrentPage.Name is whatever is the name of your Visualforce page (homepageAB?) You can read a bit more about it here and if you need - experiment with merge fields that'd mimic the methods from PageReference class (minus the "get..." part).

    Solution to your actual problem ;)

    Either go to this custom setting and modify the value in "Main URL" to add the backslash (so "xyz.com/") or modify the code to this:

    href="{!$Setup.websiteSystemVariables__c.Main_URL__c+ '/' + $CurrentPage.Name}"
    

    Just check what value you have on production and use same format in your sandbox, otherwise you might end up with 2 backslashes in the URL...