How it works:
Standalone Page Limitations:
Overview:
Standalone Integration can be used to add editable CMS content areas to existing individual pages in an application. This can be used together with, or apart from, a site with a Router Integration.
Integration:
npm install jsharmony-cms-sdk-express
// Initialize the jsHarmonyCmsRouter
const jsHarmonyCmsRouter = require('jsharmony-cms-sdk-express').Router;
const cmsRouter = new jsHarmonyCmsRouter({
cms_server_urls: ["https://cms.example.com/"],
content_path: "path/to/published_files"
});
// Example - existing page route (be sure to use the async keyword)
app.get('/standalone_page', async function(req, res, next){
// In your existing page route, load the page content and pass it as a parameter
// * If your standalone page URL does not match the CMS page path, pass the CMS page path as a parameter
var page = await cmsRouter.getStandalone(req); // or (req, '/cms_page_path');
res.render('standalone_page.ejs', { page: page });
});
* Be sure to update the "content_path" property to match the CMS files publish folder in your PHP application
<%-page.editorScript%>
<html>
<head>
<% if(page.seo.title){ %><title><%=page.seo.title%></title><% } %>
<% if(page.seo.keywords){ %><meta name="keywords" content="<%=page.seo.keywords%>" /><% } %>
<% if(page.seo.metadesc){ %><meta name="description" content="<%=page.seo.metadesc%>" /><% } %>
<% if(page.seo.canonical_url){ %><link rel="canonical" href="<%=page.seo.canonical_url%>" /><% } %>
<% if(page.css){ %><style type="text/css"><%-page.css%></style><% } %>
<% if(page.js){ %><script type="text/javascript"><%-page.js%></script><% } %>
<%-page.header%>
<%-page.editorScript%>
</head>
<body>
<h1 cms-title><%=page.title%></h1>
<div cms-content-editor="page.content.body"><%-page.content.body%></div>
<%-page.footer%>
</body>
</html>
<!-- Page Template Config -->
<script type="text/cms-page-config">
{
"default_content": { "body": "Default Page Content" },
"properties": {
"fields": [
{ "name": "showTitle", "caption": "Show Title", "control": "checkbox", "default": "Y", "controlparams": { "value_true": "Y", "value_false": "N" } },
{ "name": "containerClass", "caption": "Container CSS Class" },
{ "name": "containerStyle", "caption": "Container CSS Style" },
]
}
}
</script>
<!-- Static Page Component -->
<div cms-component="breadcrumbs" cms-component-content="breadcrumbs"><%-page.content.breadcrumbs%></div>
<!-- onRender / showIf -->
<% if(page.properties.showTitle!='N'){ %><h1 cms-title cms-onRender="showIf(page.properties.showTitle!='N');"><%=page.title%></h1><% } %>
<!-- onRender / addClass -->
<div cms-onRender="addClass(page.properties.containerClass);" class="<%=page.properties.containerClass%>"></div>
<!-- onRender / addStyle -->
<div cms-onRender="addStyle(page.properties.containerStyle);" style="<%=page.properties.containerStyle%>"></div>