Monday, 28 March 2011

Creating a Web-to-Lead Form (Part 1)

For those who follow my blog you might remember that I previously mentioned that I have been tinkering with force.com sites. Someone recently asked me to how to create Web-to-lead forms so I thought it would be great idea to go over this process in the next few posts. Implementing these forms on your force.com site will allow a company to capture a prospective customers information. In order to do this we need to create a custom contact page. This will show up when prospective customers  submit their information.

Ultimately we will have to create two Visualforce pages...in these post we will go over the 1st one which is need to display the confirmation. First you need to click 'Setup', then 'Develop', and finally 'Pages'. For the Label I suggest entering 'Thank You Page' and for the Name I suggest entering 'ThankYou'....that being said you can enter whatever you feel is appropriate. The last step is to replace the existing the Visualforce markup with the following (again you can change the title and message to what you feel is appropriate):

01        <apex:page title="Information Request" 
02                              showHeader="false" standardStylesheets="true">
03       <apex:composition template="{!$Site.Template}">
04         <apex:define name="body">
05             <br/>
06             <center>
07             <apex:outputText value="Thank You For Your Inquiry!"/>
08             </center>
09             <br/>
10             <br/>
11         </apex:define>
12       </apex:composition>
13    </apex:page>

After this is done you have to extend the standard controller in place to redirect the would be users to a custom contact page when they submit information. We have to do this because as a default Salesforce.com makes it so the standard controller directs the user to the standard detail page after saving the related record. However these standard detail pages can not be made public on via regular sites.

In the next post we will go over how to direct the users to a custom Visualforce page by creating an extension for the standard controller. Please try to control your anticipation until then...        

Tuesday, 15 March 2011

Adding Pages to the Customer Portal

In the last post we went over the basic layout and structure of creating a customer portal from a standard page. Now that we have this knowledge we can go ahead and add extra pages to our site. The following code, specifically the composite component, enables the page to use or previous site template:

<apex:page showHeader="false" standardStylesheets="true">
<apex:composition template="{!$Site.Template}">
<apex:define name="body">
<-- PAGE'S CONTENT GOES HERE -->
</apex:define>
</apex:composition>
</apex:page>

All the new pages will now utilize our template! However if you want to overwrite your existing templates data you will need to add a "apex:define" component with the same name attribute as the insert component in the template.

That being said in order to overwrite the body section of the template you will need to insert the following:

<apex:define name="body">
... PAGE'S BODY...
<
apex:define>

Now you can customize the page to a certain extent if you don't want every page to follow the established template.