Forum
Attributes not appearing on Gallery Album or Shop Product Page.
I've created a site using a global layout for the document head that includes perch_page_attributes
, these render out as HTML on all the pages of the site, with two exceptions, the gallery album page (album.php) and the shop product page (product.php).
All pages on the site use the same global layout file global.above.php. The attributes render for the top level album listing page and the product listing page, they just don't appear at all for those two pages.
Are these supposed to work with these pages? If so, am I missing something out?
My plan is to extend them using perch_page_attributes_extend
but I can't do that if they're not rendering at all. I've filled in the details with the Page Details section in the CMS for these pages, but that makes no difference.
global.above.php
<?php
perch_content_create('Business Details', array(
'template' =>'shared/_business_details.html',
'shared' =>true,
'multiple' =>false,
'edit-mode' =>'singlepage',
'searchable' =>false,
));
$meta = perch_content_custom('Business Details', array(
'skip-template'=>true,
));
if (is_array($meta) && isset($meta[0])) {
$meta = $meta[0];
}else{
$meta['site_name'] = 'Name';
$meta['site_strapline'] = 'Strapline';
$meta['site_phone'] = '01234 567 890';
$meta['site_email'] = 'info@domain.com';
}
PerchSystem::set_vars($meta);
$body_class = '';
$parts = explode('/', $Perch->get_page());
if (isset($parts[1]) && $parts[1]!='index.php') $body_class = $parts[1];
?>
<!DOCTYPE html>
<html>
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8" />
<?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) header('X-UA-Compatible: IE=edge,chrome=1'); ?>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?php if (perch_layout_var('homepage', true)) { echo ''; } else if (perch_layout_var('title', true)) { echo perch_layout_var('title'). ' · '; } else { echo perch_pages_title(). ' · '; } ?><?php echo $meta['site_name']; ?> · <?php echo $meta['site_strapline']; ?></title>
<!-- Author & Page Info
================================================== -->
<?php
$domain = 'https://'.$_SERVER["HTTP_HOST"];
$url = $domain.$_SERVER["REQUEST_URI"];
$sitename = $meta['site_name'];
$twittername = "@twitter";
$sharing_image = '/_assets/img/fb/ogimage.jpg';
PerchSystem::set_var('domain',$domain);
PerchSystem::set_var('url',$url);
PerchSystem::set_var('sitename',$sitename);
PerchSystem::set_var('sharing_image',$sharing_image);
PerchSystem::set_var('twittername',$twittername);
perch_page_attributes(array(
'template' => 'default.html'
));
?>
<link rel="author" type="text/plain" href="/humans.txt" />
<link rel="canonical" href="<?php $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>" />
<!-- REMOVE BEFORE LAUNCH
================================================== -->
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="/_assets/ico/favicon.ico">
<link rel="apple-touch-icon" href="/_assets/ico/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="/_assets/ico/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/_assets/ico/apple-touch-icon-114x114.png">
<!-- CSS
================================================== -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Playfair+Display:400italic">
<link rel="stylesheet" href="/_assets/css/site.css"><!-- To be minified and combined -->
<?php //perch_get_css(); ?>
<!-- Scripts
================================================== -->
<script>
// Picture element HTML5 shiv
document.createElement( "picture" );
</script>
<script src="/_assets/js/vendor/picturefill.min.js" async></script>
</head>
<body class="<?php echo PerchUtil::html($body_class, true); ?>">
<div class="full top">
<div class="container">
<header class="masthead">
<div class="row">
<div class="col-xxs-4 col-s-3">
<a href="/" class="logo"><img src="/_assets/img/gmwc-logo-white.svg" alt="<?php echo $meta['site_name']; ?>" /></a>
</div>
<div class="col-s-9">
<div class="masthead-detail">
<div class="shopping-cart hidden-xxs hidden-xs">
<?php
perch_shop_custom(array(
'count'=>'1',
'template'=>'shop/view_cart.html'
));
?>
</div>
<div class="strapline"><?php echo $meta['site_strapline']; ?></div>
<div class="quick-contact hidden-xxs hidden-xs">
<div class="phone"><i class="fa fa-phone"></i> <?php echo $meta['site_phone']; ?></div>
<div class="email"><i class="fa fa-envelope"></i> <a href="mailto:<?php echo $meta['site_email']; ?>?subject=Website%20Enquiry"><?php echo $meta['site_email']; ?></a></div>
</div>
</div>
</div>
</div>
</header>
</div>
<div class="full top-border"></div>
</div>
<div class="full middle">
<div class="container">
<div class="row equal-height">
<div class="col-s-9 push-s-3">
<main class="main">
<?php if (perch_layout_var('homepage', true)) { echo perch_content('Featured Pages'); } ?>
<h1 class="heading alpha"><?php if (perch_layout_var('homepage', true)) { echo $meta['site_name']; } else if (perch_layout_var('title', true)) { echo perch_layout_var('title'); } else { echo perch_pages_title(); }?></h1>
album.php
<?php
include($_SERVER['DOCUMENT_ROOT'].'/office/runtime.php');
PerchSystem::force_non_ssl();
perch_layout('global.above', array(
'title' => perch_gallery_album_field(perch_get('s'), 'albumTitle', true),
));
if(perch_get('s')) {
perch_gallery_album_images(perch_get('s'), array(
'template' =>'list_image.html'
));
}
perch_layout('global.below');
?>
product.php
<?php
include($_SERVER['DOCUMENT_ROOT'].'/office/runtime.php');
PerchSystem::force_ssl();
perch_layout('global.above', array(
//'title' => perch_page_title(true),
'title' => perch_shop_product_field(perch_get('s'), 'productTitle', true),
//Page Specific
'tasting-events' => true,
'tasting-event-detail' => true,
));
PerchSystem::set_var('cutoff', date('Y-m-d H:i:s', strtotime('+3 hours', time()))); // productDate -3 hours
perch_shop_product(perch_get('s'));
?>
<div class="share-links">
<a class="share share-tweet" target="_blank" href="https://twitter.com/intent/tweet?text=<?php $title=perch_shop_custom(array('filter'=>'productSlug','match'=>'eq','value'=>perch_get('s'),'template'=>'shop/product_title.html'));$date=perch_shop_custom(array('filter'=>'productSlug','match'=>'eq','value'=>perch_get('s'),'template'=>'shop/product_date.html')); echo $title,$date; ?>&url=<?php $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>&via=twitter">Tweet This</a>
<a class="share share-facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>">Share on Facebook</a>
<a class="share share-linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>">Share on LinkedIn</a>
<a class="share share-google" target="_blank" href="https://plus.google.com/share?url=<?php $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>">Share on Google+</a>
</div>
<?php
perch_layout('global.below', array(
//Page Specific
'tasting-events' => true,
'tasting-event-detail' => true,
));
?>
The rest of the pages are pretty much like this index.php and all work as expected:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/office/runtime.php');
PerchSystem::force_ssl();
perch_layout('global.above', array(
//Page Specific
'homepage' => true,
));
perch_content('Main Content');
perch_layout('global.below', array(
//Page Specific
'homepage' => true,
));
?>
attributes/default.html
<perch:template path="pages/attributes/seo.html" />
<perch:template path="pages/attributes/facebook.html" />
<perch:template path="pages/attributes/twitter.html" />
attributes/facebook.html
<meta property="og:site_name" content="<perch:pages id="sitename" type="hidden" />" />
<meta property="og:url" content="<perch:pages id="url" type="hidden" />" />
<meta property="og:title" content="<perch:pages id="og_title" label="Social title" type="text" escape="true" help="Title for this document with no branding or site name" divider-before="Facebook Open Graph Tags" />" />
<meta property="og:description" content="<perch:pages id="og_description" label="Social description" type="textarea" size="s" escape="true" />" />
<perch:if exists="og_image"><meta property="og:image" content="<perch:pages id="domain" type="hidden" /><perch:pages id="og_image" label="Image when shared" help="Should be at least 1200x630" type="image" width="1200" />" /><perch:else /><meta property="og:image" content="<perch:pages id="domain" type="hidden" /><perch:pages id="sharing_image" type="hidden" />" /></perch:if>
<perch:if exists="og_type"><meta property="og:type" content="<perch:pages id="og_type" label="Facebook type" type="select" options="article,book,profile,website,video,music" allowempty="true" />" /></perch:if>
<perch:if exists="og_author"><meta property="article:author" content="<perch:pages id="og_author" type="hidden" />" /></perch:if>
attributes/seo.html
<meta name="description" content="<perch:pages id="description" label="Description" type="textarea" size="xs" escape="true" count="chars" />" />
<meta name="keywords" content="<perch:pages id="keywords" label="Keywords" type="textarea" size="xs" escape="true" help="Separate with commas" count="chars" />" />
<meta name="robots" content="<perch:pages id="noindex" label="Do not index" type="checkbox" value="noindex" append="," divider-before="Search engine indexing" /><perch:pages id="nofollow" label="Do not follow links" type="checkbox" value="nofollow" append="," /><perch:pages id="nosnippet" label="Do not show a snippet" type="checkbox" value="nosnippet" append="," />" />
attributes/twitter.html
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="<perch:pages id="twittername" type="hidden" />" />
<meta name="twitter:title" content="<perch:pages id="og_title" label="Social title" type="text" escape="true" help="Title for this document with no branding or site name" />" />
<meta name="twitter:description" content="<perch:pages id="og_description" label="Social description" type="textarea" size="s" escape="true" />" />
<perch:if exists="og_image"><meta property="twitter:image" content="<perch:pages id="domain" type="hidden" /><perch:pages id="og_image" label="Image when shared" help="Should be at least 1200x630" type="image" width="1200" />" /></perch:if><meta name="twitter:url" content="<perch:pages id="url" type="hidden" />" />
Diagnostics
PERCH INFORMATION
Perch: 2.8.13
Production mode: (PERCH_DEVELOPMENT)
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_forms (1.8.3), perch_gallery (2.8.6), perch_mailchimp (2.0.1), perch_shop_paypal (1.2.3), perch_backup (1.2)
DB driver: PDO
DB tables: perch2_categories, perch2_category_counts, perch2_category_sets, perch2_content_index, perch2_content_items, perch2_content_regions, perch2_forms, perch2_forms_responses, perch2_gallery_albums, perch2_gallery_image_versions, perch2_gallery_images, perch2_mailchimp_campaigns, perch2_mailchimp_history, perch2_mailchimp_log, perch2_mailchimp_stats, perch2_mailchimp_subscribers, perch2_navigation, perch2_navigation_pages, perch2_page_templates, perch2_pages, perch2_resource_log, perch2_resource_tags, perch2_resources, perch2_resources_to_tags, perch2_settings, perch2_shop_categories, perch2_shop_log, perch2_shop_orders, perch2_shop_product_options, perch2_shop_products, perch2_shop_products_to_categories, perch2_user_privileges, perch2_user_role_privileges, perch2_user_roles, perch2_users
Users: 2
App runtimes:
<?php
$apps_list = array(
'content',
'categories',
'perch_forms',
'perch_gallery',
'perch_shop_paypal',
'perch_mailchimp',
);
Scheduled tasks for perch_mailchimp: update_list_stats (60 mins)
Editor plug-ins: markitup, redactor
H1: ca1d8d50925f7f9d76107223c39daa79
L1: 5ac919b3371cb7089a9c79cb6a05e219
headerColour: #5f171f
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.13: done
latest_version: 2.8.8
on_sale_version: 2.8.13
headerScheme: dark
perch_gallery_bucket_mode: dynamic
perch_gallery_bucket: gallery
perch_mailchimp_campaign_url: /mailchimp/campaign.php?s={campaignSlug}
perch_shop_product_url: /tasting-events/{productSlug}
dashboard: 1
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_gallery_basicUpload: 0
perch_shop_display_oos: 1
perch_mailchimp_api_key: 4f1b8b804498e6d851b0cb1c0a7a1597-us8
perch_mailchimp_list_id: ab08f6bfa3
perch_shop_paypal_email: sales@glasgowmaltwhiskycompany.com
logoPath: /office/resources/gmwc-logo-300px.png
perch_gallery_update: 2.8.5
perch_mailchimp_secret: beba95d4e6e220f893f0861b9b9367c8
perch_mailchimp_update: 2.0
perch_backup_mysqldump_path: C:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump.exe
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: admin_iain
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: glasgowmaltwhiskycompany.local
PERCH_SSL:
PERCH_DB_PREFIX: perch2_
PERCH_TZ: Europe/London
PERCH_EMAIL_FROM: iain@darkflaredesign.co.uk
PERCH_EMAIL_FROM_NAME: Iain Fergus
PERCH_LOGINPATH: /office
PERCH_PATH: C:\wamp\www\glasgowmaltwhiskycompany.local\office
PERCH_CORE: C:\wamp\www\glasgowmaltwhiskycompany.local\office\core
PERCH_RESFILEPATH: C:\wamp\www\glasgowmaltwhiskycompany.local\office\resources
PERCH_RESPATH: /office/resources
PERCH_HTML5: 1
PERCH_RWD: 1
PERCH_DEBUG:
PERCH_PRODUCTION_MODE: PERCH_DEVELOPMENT
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: C:\wamp\www\glasgowmaltwhiskycompany.local\office\templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_HTML_ENTITIES:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS
PHP: 5.5.12
Zend: 2.5.0
OS: WINNT
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $
MySQL server: 5.6.17
Extensions: Core, bcmath, calendar, ctype, date, ereg, filter, ftp, hash, iconv, json, mcrypt, SPL, odbc, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, wddx, xml, xmlreader, xmlwriter, apache2handler, openssl, curl, com_dotnet, fileinfo, gd, gettext, gmp, imap, mbstring, exif, mysql, mysqli, Phar, pdo_mysql, pdo_sqlite, shmop, soap, sockets, sqlite3, xmlrpc, xsl, mhash, xdebug
GD: Yes
ImageMagick: No
PHP max upload size: 64M
PHP max form post size: 64M
PHP memory limit: 128M
Total max uploadable file size: 64M
Resource folder writeable: Yes
Session timeout: 30 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: No
HTTP_HOST: glasgowmaltwhiskycompany.local
HTTP_CONNECTION: keep-alive
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36
HTTP_REFERER: https://glasgowmaltwhiskycompany.local/office/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8,en-GB;q=0.6
HTTP_COOKIE: _ga=GA1.2.1009028949.1437308162; cmsa=1; PHPSESSID=68ikccm3ochnfg2b1arlvd1mm1
PATH: C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\nodejs\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\Skype\Phone\;
SystemRoot: C:\Windows
COMSPEC: C:\Windows\system32\cmd.exe
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR: C:\Windows
SERVER_SIGNATURE: <address>Apache/2.4.9 (Win64) PHP/5.5.12 Server at glasgowmaltwhiskycompany.local Port 80</address>
SERVER_SOFTWARE: Apache/2.4.9 (Win64) PHP/5.5.12
SERVER_NAME: glasgowmaltwhiskycompany.local
SERVER_ADDR: 127.0.0.1
SERVER_PORT: 80
REMOTE_ADDR: 127.0.0.1
DOCUMENT_ROOT: C:/wamp/www/glasgowmaltwhiskycompany.local
REQUEST_SCHEME: http
CONTEXT_DOCUMENT_ROOT: C:/wamp/www/glasgowmaltwhiskycompany.local
SERVER_ADMIN: admin@example.com
SCRIPT_FILENAME: C:/wamp/www/glasgowmaltwhiskycompany.local/office/core/settings/diagnostics/index.php
REMOTE_PORT: 52171
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /office/core/settings/diagnostics/?extended
SCRIPT_NAME: /office/core/settings/diagnostics/index.php
PHP_SELF: /office/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1443283044.631
REQUEST_TIME: 1443283044
What's different about those pages compared to the pages that are working as you'd expect?
Hi Drew, do you mean in my templates, or that they are list and detail type pages generated by apps?
I mean what can you tell me about them that would give me something to go on. There must be something different to result in your code not working on these pages when it does on others.
Looks like I've found the problem…mistake at my end.
It wasn't in the templates at all, but in the page settings. I'd stupidly managed to create the path of the subpages as /tasting-events/tasting-events/index.php instead of /tasting-events/index.php when adding them into the CMS.
Fixed these and the attributes are now appearing, and I've been able to extend them.