You need to sign in to do that
Don't have an account?
Would You Do This?
I am very new to apex, coming from PHP.
I am helping out a company that I think is being way overquoted for a website. So, I am looking into Apex, and seeing if I can keep them honest.
I just want to know if I am on the right track.
We need a multi page website (40). There are 5 different headers and footers (Different Sections of the site). The content for almost every page it text and a couple of images.
So here is my approach.
Build 1 site.
Build the 5 headers and 5 footers as componants.
Build a visual force page for each page of the site and call upon the componants for the headers and footers.
Create a controller for each page (Example Below) to get the data from the cms object.
Within the controller, add a test class that checked out at 100% (Also Below).
Make sure the security settings allow the public to view the pages.
All I want to know, is if I am on the right track? Would you do something differently?
Here is a sample of the controller to get the data. Once again, on the right track?
public class Web_Property_Home { private final Website_Page__c field; public Web_Property_Home() { field = [select name,id,Main_Heading__c,Main_Text__c,Text_Field_1__c,Text_Field_2__c, Text_Field_3__c,Sub_Heading_1__c,Sub_Heading_2__c,Sub_Heading_3__c,Image_1__c,Image_2__c from Website_Page__c where Name = 'Home Page' Limit 1]; } public Website_Page__c getfield() { return field; } static testMethod void Web_Property_Home(){ Website_Page__c objWeb = new Website_Page__c(); objWeb.Name = 'Home Page'; insert objWeb; Web_Property_Home objClass = new Web_Property_Home (); objClass.getfield(); system.assert(objClass.field != null); } }
I think you are more or less on the right track. I might look at using component controllers for the specific navigation layout, because would probably allow you to make a more generic, flexible framework.
Also, before you roll your own too much - have you looked the CMSForce Force.com Labs project?
http://appexchange.salesforce.com/listingDetail?listingId=a0N30000001SlHNEA0
It might save you some time.