[英]How to add header html to VF page
<apex:page showheader="false" sidebar="false">
</head>
<body>
<div>
Header html should load here
</div>
</body>
</html>
</apex:page>
I have a html file with some heading html codes. 我有一个带有一些标题html代码的html文件。 'header.html' how to include this file to my VF page as dynamic header?
'header.html'如何将此文件作为动态标题包含到我的VF页面中?
Salesforce store your HTML file inside the database as metadata, so this means that it can be queried for. Salesforce将HTML文件作为元数据存储在数据库中,因此这意味着可以对其进行查询。
You'll need a controller extension for your <apex:page>
. 您需要为
<apex:page>
扩展控制器。 Check this link on how to do that. 检查此链接以了解有关操作方法。
So, your controller will have a method like so: 因此,您的控制器将具有如下方法:
public string getHeaderHtml() {
try {
return [Select Body From Document Where Id = 'YOUR_PAGE_ID'].Body.toString();
} catch(exception e) {
return '';
}
}
And in your Visualforce page you'll have this line where you want your HeaderHtml to be placed: 在Visualforce页面中,您将有以下行希望放置HeaderHtml:
<apex:outputText escape="false" value="{!HeaderHtml}"/>
OR 要么
Alternative option is to use <apex:iframe>
with it's src
pointing to your header file url like src="/apex/MyPage"
. 另一种选择是使用
<apex:iframe>
,它的src
指向您的头文件url,如src="/apex/MyPage"
。 Check the documentation link . 检查文档链接 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.