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
ram2forceram2force 

how to give link from Site page to visual force page

I have created a visual force page(using setup>Develop>pages) and add this page to my site(using Develop>sites>MysiteName>Site visualforce pages>Edit>add  and save my visualforce page).

 

Visual force page:

 

 

<apex:page >
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 Then I have added Active site page of my site as, SiteTemplate. The coding of site template is below.

 

Site Template:

 

 

<apex:page showHeader="false" id="SiteTemplate">
  <apex:stylesheet value="{!URLFOR($Resource.SiteSamples, 'SiteStyles.css')}"/>
  <apex:insert name="header">
  </apex:insert>
  <apex:insert name="body"> 

<h1>My First Website<h1>
<a href="???">My Congratulations page</a>
</apex:insert>
<apex:insert name="footer">
<hr/>
<c:SiteFooter />
<site:googleAnalyticsTracking />
</apex:insert>
</apex:page>

 

My need is, If click on "My congratulations page" in my site page.....the Visual force page "Congratulations" should show......How to do this????......

 

Please clear my issue.......

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

if you are in a Force.com site and your visualforce page called "Hello" is also available to the site, you should just be able to use the page name as is.

 

Do any of the following work for you:

 

 

<apex:outputLink value="/apex/Hello">Hello</apex:outputLink>
<apex:outputLink value="/Hello">Hello</apex:outputLink>
<apex:outputLink value="../Hello">Hello</apex:outputLink>

 

 

All Answers

bob_buzzardbob_buzzard

You should just be able to refer to the page name (I tend to use ../ as it handles the case where my site isn't at the root directory level) :

 

 

<a href="../Congratulations">My Congratulations page</a>

 

 

ram2forceram2force

could you please provide any sample path the link of the visualforce page......

 

like,  href= " .....???...../Congratulations"

 

I tried like, but it is not working.......

 

 

<a href="/hello">My link to Hello page</a>

bob_buzzardbob_buzzard

if you are in a Force.com site and your visualforce page called "Hello" is also available to the site, you should just be able to use the page name as is.

 

Do any of the following work for you:

 

 

<apex:outputLink value="/apex/Hello">Hello</apex:outputLink>
<apex:outputLink value="/Hello">Hello</apex:outputLink>
<apex:outputLink value="../Hello">Hello</apex:outputLink>

 

 

This was selected as the best answer
ram2forceram2force

Thank you very much Mr.Bob...First one is worked  Accurately...........Similar way I can add Add visual force pages to my site and give link to that page unlimited.....is it correct...........Thank you....

bob_buzzardbob_buzzard

I think so, assuming I'm understanding you correctly. You can use this for any pages that are available to your site.

new2forcenew2force

hey u can also do like

 

<a href="/<Site Label>/<UR VF page name>"

  give it a try

 

when using PageReference do like

 new PageReference('/<Ur VF page name>')

TopalovichTopalovich

Why would you not use the $Page global variable?

 

 

<apex:outputLink value="{!$Page.YourVisualForcePage}">Congratulations Page.</apex:outputLink>