Template: shared/share_settings.html
<title><perch:content id="share_title" type="hidden"> | <perch:content id="website_title" type="text" label="Website Title" required title></title>
<perch:content id="seo_meta" type="hidden" encode="false">
<link rel="canonical" href="<perch:content id="canonical_url" type="hidden">" />
<meta property="og:title" content="<perch:content id="share_title" type="hidden">" />
<meta property="og:type" content="<perch:content id="share_type" type="hidden">" />
<meta property="og:url" content="<perch:content id="share_url" type="hidden">" />
<meta property="og:image" content="<perch:content id="prot_dom" type="hidden"><perch:if exists="share_img"><perch:content id="share_img" type="hidden"><perch:else /><perch:content type="image" id="image" label="Default Share Image" help="1200x630px JPG or PNG"></perch:if>" />
<meta property="og:site_name" content="<perch:content id="website_title" type="text" label="Website Title" required title>" />
<meta name="twitter:card" content="summary_large_image" />
<perch:if exists="twitter"><meta name="twitter:site" content="@<perch:content id="twitter" type="text" label="Twitter Account" help="Enter default Twitter account, excluding @">" /></perch:if>
Layout: header.php
<?php
// GLOBAL PERCH IDS
// prot_dom: protocol & domain
PerchSystem::set_var('prot_dom',(isset($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']);
// share_title: page title
PerchSystem::set_var('share_title',perch_layout_has('title') ? perch_layout_var('title',true) : perch_pages_title(true));
// share_type: OG type, default to 'website'
PerchSystem::set_var('share_type',perch_layout_has('share-type') ? perch_layout_var('share-type',true) : 'website');
// share_url: page URL
PerchSystem::set_var('share_url',perch_layout_has('share-url') ? perch_layout_var('share-url',true) : perch_page_url([],true));
// share_img: defaults to image in share_settings.html
if (perch_layout_has('share-img')) { PerchSystem::set_var('share_img', perch_layout_var('share-img',true)); }
// perch seo meta tags
PerchSystem::set_var('seo_meta',perch_page_attributes([],true));
// canonical_url: default to share_url, enable override if different
PerchSystem::set_var('canonical_url',perch_layout_has('canonical') ? perch_layout_var('canonical',true) : PerchSystem::get_var('share_url'));
perch_content_create('Share Settings', array(
'template' => 'shared/share_settings.html',
'multiple' => false,
));
perch_content_custom('Share Settings');
?>
Example List/Detail Master Page:
<?php
// DETAIL PAGE
if (perch_get('s')) {
// get base URL
$page_url = perch_page_url([],true);
// get detail content
$result = perch_collection('News',[
'filter'=>'slug',
'match'=>'eq',
'value'=>perch_get('s'),
'skip-template'=>true,
'return-html'=>true
],true);
// CHECK 404
if (empty(array_filter($result))) {
PerchSystem::use_error_page(404);
exit;
}
// POST EXISTS, OUTPUT PAGE
else {
// override page description with template excerpt
perch_page_attributes_extend([
'description' => $result[0]['excerpt']
]);
// output header, override default meta tags
perch_layout('global/header',[
'title' => $result[0]['title'],
'share-type' => 'article',
'share-url' => $page_url.'/'.$result[0]['slug'],
'share-img' => $result[0]['image'],
]);
// output content
echo $result['html'];
perch_layout('global/footer');
}
}
// LIST PAGE
else {
perch_layout('global/header');
perch_collection('News',[
'template'=>'news/_list_item.html',
'sort' => '_order',
'sort-order' => 'asc',
]);
perch_layout('global/footer');
}