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.
// If not already included in your application, auto-load Composer
require_once __DIR__.'/vendor/autoload.php';
// Initialize the jsHarmony CMS Router
use apHarmony\jsHarmonyCms\CmsRouter;
$cmsRouter = new CmsRouter([
"redirect_listing_path" => "jshcms_redirects.json",
"cms_server_urls" => ["https://localhost:8081/"],
"content_path" => $_SERVER['DOCUMENT_ROOT']."/path/to/published_files"
]);
// Get the CMS content for this page
$page = $cmsRouter->getStandalone();
* Be sure to update the "content_path" property to match the CMS files publish folder in your PHP application
<?=$page->editorScript?>
<html>
<head>
<?php if($page->seo->title){ ?><title><?=htmlspecialchars($page->seo->title)?></title><?php } ?>
<?php if($page->seo->keywords){ ?><meta name="keywords" content="<?=htmlspecialchars($page->seo->keywords)?>" /><?php } ?>
<?php if($page->seo->metadesc){ ?><meta name="description" content="<?=htmlspecialchars($page->seo->metadesc)?>" /><?php } ?>
<?php if($page->seo->canonical_url){ ?><link rel="canonical" href="<?=htmlspecialchars($page->seo->canonical_url)?>" /><?php } ?>
<?php if($page->css){ ?><style type="text/css"><?=$page->css?></style><?php } ?>
<?php if($page->js){ ?><script type="text/javascript"><?=$page->js?></script><?php } ?>
<?=$page->header?>
<?=$page->editorScript?>
</head>
<body>
<h1 cms-title><?=htmlspecialchars($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 -->
<?php if($page->properties->showTitle!='N'){ ?><h1 cms-title cms-onRender="showIf(page.properties.showTitle!='N');"><?=htmlspecialchars($page->title)?></h1><?php } ?>
<!-- onRender / addClass -->
<div cms-onRender="addClass(page.properties.containerClass);" class="<?=htmlspecialchars($page->properties->containerClass)?>"></div>
<!-- onRender / addStyle -->
<div cms-onRender="addStyle(page.properties.containerStyle);" style="<?=htmlspecialchars($page->properties->containerStyle)?>"></div>