In Part 1 of this series, I looked at how to turn an HTML page into a Visualforce page in order to use it as a template for a Force.com site. Part 2 covered how to turn the page into a template and create a home page that used the template to provide the common content.
Up to now the pages have only been available to users that have logged in to the Salesforce system. This post will show how to expose the pages in a Force.com site, to allow access from the wider web.
Before creating a Force.com site I have to choose my domain name - so I navigate to Setup -> App Setup -> Develop -> Sites and the following page is presented:
As I'm using a Force.com Free Edition org (yes, I was lucky enough to be able to grab a couple of these when they were available - I only wish I'd had the foresight to grab about 50!) I can't change the rather ugly default domain name, but in Enterprise/Unlimited Edition you can choose what you like, as long as someone else hasn't taken it. I'm not stuck with this domain name however, as I can define a custom 'vanity' URL for my site, which I'll set up later.
Ticking the box and confirming that I understand I can't change the domain name, registers my domain and takes me to the back to the Sites page with my domain defined.
I then click the 'New' button to create my new site. As this is for demo purposes only, I've filled in the minimum amount of information. If you'd like more information on the purpose of each of these fields, check the help page by clicking the 'Help for this Page' link at the top right.
As I have specified my 'home' Visualforce page, this is automatically included in the list of pages for the site:
As an aside, whenever you add a Visualforce page to a site, your site automatically gets access to any Apex classes that it depends on.
And that's it! I can now navigate to the default site address and access my page without going through any form of authentication.
While my site is now available on the internet, the chances of anyone bothering to type in the full URL are pretty slim, so the next task is to set up the vanity URL. This has to be a CNAME redirect from my personal domain to the Force.com site domain name. In my case I'm going to create a subdomain to bobbuzzard.org of example.bobbuzzard.org. My registration system is Freeparking, and I have to set up an alias to the Force.com A record in order for the CNAME record to be created:
I can then verify that my record has been created using an online nslookup tool:
Finally, update the site configuration to define the custom URL:
Sometimes the DNS records don't propagate for a while, so if the vanity URL doesn't work, give it a couple of hours and try again.
Accessing my site via http://example.bobbuzzard.org shows that everything is set up correctly and propagated:
In the next post I'll add pages for one or two of the other tabs and show one way to highlight the tab associated with the page.
No comments:
Post a Comment