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
kiran k 12kiran k 12 

I have couple of pages in an application Says as page1 ,page2,page3,page4,page5.All the five pages are having same content as footer and header?? when i add some sentences on page 1 ,it should appear in all the pages .How can u achieve this??

Best Answer chosen by kiran k 12
Sameer Tyagi SFDCSameer Tyagi SFDC
Hi Kiran, 

You can achieve this by creating a visualforce component. 

Instead of adding sentences in page 1, add your sentence in component and use that component  in your all VF pages. 
Help articles
http://www.salesforce.com/docs/developer/pages/Content/pages_comp_cust_creating.htm
http://www.salesforce.com/docs/developer/pages/Content/pages_comp_cust_using.htm

OR 
You can use custum settings to achieve this. 
Save some text(sentences) in Custom settings and use that custom settings on your vf pages. 
If you want to change sentence anytime, you just need to change in Custom settings. 

Thanks & Regards, 
Sameer Tyagi
http://mirketa.com/

 

All Answers

Sameer Tyagi SFDCSameer Tyagi SFDC
Hi Kiran, 

You can achieve this by creating a visualforce component. 

Instead of adding sentences in page 1, add your sentence in component and use that component  in your all VF pages. 
Help articles
http://www.salesforce.com/docs/developer/pages/Content/pages_comp_cust_creating.htm
http://www.salesforce.com/docs/developer/pages/Content/pages_comp_cust_using.htm

OR 
You can use custum settings to achieve this. 
Save some text(sentences) in Custom settings and use that custom settings on your vf pages. 
If you want to change sentence anytime, you just need to change in Custom settings. 

Thanks & Regards, 
Sameer Tyagi
http://mirketa.com/

 
This was selected as the best answer
Ankit Maini.Ankit Maini.
Are you talking about the resuability of the code If yes than you can use components as seperate page:

Here is an example how component look like:
Filie Name: myComponent.component

<apex:component >

//Here is the common code for all the pages, You can create a simple header/footer or you can include all common javascript/Css etc.

</apex:component>

To use this component just use it in this way:
<apex:page standardController="Account">
   This is my <i>page</i>. <br/>
   <c:myComponent/>
</apex:page>

Here "myComponent" is the name of the component.

Here is the example of visualforce page execution to understand how component works.
http://www.salesforce.com/docs/developer/pages/Content/pages_controller_lifecycle_example.htm

Another way is using compositions :
http://www.salesforce.com/docs/developer/pages/Content/pages_templates_composition.htm


Thanks
Ankit Maini