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
RuchieRuchie 

How to read the contents of css/HTML file placed in documents or Static Resources.

Hi,

Can anyone please help, how to read the contents of the CSS file or any other file placed in the documents. I need this, so that i can read the contents of CSS and modify the code accordingly, instead modifying in the CSS. Also, this is required, if i place the HTML static code in documents and name the file as header, footer. SO, i need to read the HTML content fom that file, and create the static HTML on the VF Page. I want to use that file as template in the VF page. Please help.

 

Thanks

John L.John L.

For .css files:

 

 

<HEAD>

. . . . 

<LINK href="{!$Resource.myresourcename}" rel="stylesheet" type="text/css">
. . . .

</HEAD>

 

 

For .html files:

 

 

<apex:include pageName="mypagename"/>

wesnoltewesnolte

Hey

 

Salesforce has ways to create templates using <apex:composition>, <apex:define>  and <apex:insert>. Using documents for templating and CSS is going to be unnecessarily difficult. And example of the above use is

 

Create a page called MyTemplate.page and code it thus

 

<apex:page id="TheTemplate">

 

<apex:insert name="header"/>

<apex:insert name="body"/> 

 

</apex:page> 

 

And in the page using the template

 

<apex:page>

 

<apex:composition template="TheTemplate">

<apex:define name="header">

  <h2>Hello</h2>

</apex:define> 

<apex:define name="body">

  <!-- The rest of you page here -->

</apex:define> 

 

</apex:composition> 

</apex:page>

 

You can use static resources for CSS and include them in the page, although I recommend using components. An example of this can be found here.

 

Wes