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:
composer require apharmony/jsharmony-cms-sdk-php
* Alternatively, the SDK can be downloaded directory from the Github jsharmony-cms-sdk-php project.
use apHarmony\jsHarmonyCms\CmsRouter;
//...
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$cmsRouter = new CmsRouter([
"redirect_listing_path" => "jshcms_redirects.json",
"cms_server_urls" => ["https://cms.example.com/"],
"content_path" => $_SERVER['DOCUMENT_ROOT']."/path/to/published_files"
]);
$cmsPath = $request->getUri()->getPath();
return new HtmlResponse($this->template->render('app::standalone_page', [ 'page' => $cmsRouter->getStandalone($cmsPath) ]));
}
* Be sure to update the "content_path" property to match the CMS files publish folder in your Zend / Laminas project
{{ page.editorScript|raw }}
<html>
<head>
{% if (page.seo.title) %}<title>{{ page.seo.title }}</title>{% endif %}
{% if (page.seo.keywords) %}<meta name="keywords" content="{{ page.seo.keywords }}" />{% endif %}
{% if (page.seo.metadesc) %}<meta name="description" content="{{ page.seo.metadesc }}" />{% endif %}
{% if (page.seo.canonical_url) %}<link rel="canonical" href="{{ page.seo.canonical_url }}" />{% endif %}
{% if (page.css) %}<style type="text/css">{{ page.css|raw }}</style>{% endif %}
{% if (page.js) %}<script type="text/javascript">{{ page.js|raw }}</script>{% endif %}
{{ page.header|raw }}
{{ page.editorScript|raw }}
</head>
<body>
<h1 cms-title>{{ page.title }}</h1>
<div cms-content-editor="page.content.body">{{ page.content.body|raw }}</div>
{{ page.footer|raw }}
</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|raw }}</div>
<!-- onRender / showIf -->
{% if (page.properties.showTitle!='N') %}
<h1 cms-title cms-onRender="showIf(page.properties.showTitle!='N');">{{ page.title }}</h1>
{% endif %}
<!-- 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>