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
Alex SashaAlex Sasha 

How to set urls porperly in Saleforce Force.com site?


in my pages i have several links to another visualforce pages in developer edition I used hard coded links such like this:
<apex:outputLink value="https://c.eu6.visual.force.com/apex/gindex" id="theLink">Back to shop</apex:outputLink>

On controller side
Public PageReference backToPage(){

            return new PageReference('/apex/gindex');
        }

How to set them properly in force.com site?
Best Answer chosen by Alex Sasha
Sagar PareekSagar Pareek
Hi Alex,
You can use {!$Site.pageName} when working with the output or command links on visualforce pages.Where pageName denotes the name of your page ( in your case it is gIndex).

Your controller seems to be correct.

On your Site's Public Access Setting make sure the visualforce page gindex is assinged under Visualforce Pages Section.


 

All Answers

Neetu_BansalNeetu_Bansal
Hi Alex,

Create an action function like below:
<apex:actionFunction name="goToShop" action="{!backToPage}" />
And update the link like this:
<a onClick="goToShop();" id="theLink">Back to shop</a>
Let me know if this helps you.

Thanks,
Neetu
Alex SashaAlex Sasha

 Sorry, maybe I have  not clarified it fully. I mean  Are that redirects will work when I  will download my pages on force.com site?

 
return new PageReference('/apex/gindex');
Neetu_BansalNeetu_Bansal
Hi Alex,

If you add permissions for these visualforce pages in your force.com site, then it will work fine.

Let me know if this helps you.

Thanks,
Neetu
Sagar PareekSagar Pareek
Hi Alex,
You can use {!$Site.pageName} when working with the output or command links on visualforce pages.Where pageName denotes the name of your page ( in your case it is gIndex).

Your controller seems to be correct.

On your Site's Public Access Setting make sure the visualforce page gindex is assinged under Visualforce Pages Section.


 
This was selected as the best answer