We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem, Runway

using page attributes as template include in perch_collection not working

Hi,

I'm trying to output page attributes (meta info in the head) for a runway collection item using a template include i.e.:

        perch_collection('Walks', [
            'template' => 'collections/_meta.html',
            'filter'=> 'slug', 
            'match' => 'eq', 
            'value' => perch_get('walkSlug'),
            'count' => 1,
        ]);

_meta.html

<perch:template path="pages/attributes/default.html" rescope="parent" />

The template markup is output but without any data / variables (<perch:pages id="description">, etc are empty).

If I copy & paste the contents of default.html into _meta.html and replace all perch:pages tags with perch:content tags the data variables are output fine, so there is a solution but it makes sense to be able to rescope & reuse these page attributes templates... Should this be possible?

Thanks!

Adam Green

Adam Green 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, what does it output at the bottom of the page?

Debug showing the templates are found (template markup is present to prove it) - it just doesn't insert the data where the template tags are.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does <perch:showall> show the ID values you're using in the template?

Thanks Drew.

Yes <perch:showall> displays all the ID values used in the template, they're just not output in the markup. I wondered if there were 2 many levels of template includes, as default.html contains 3 further template includes (seo, facebook & twitter). I had to update the paths for these, i.e. default.html:

<perch:template path="pages/attributes/seo" />
<perch:template path="pages/attributes/facebook" />
<perch:template path="pages/attributes/twitter" />

Also added rescope="parent" to each include above and called default.html directly from perch_collection, i.e.

perch_collection('Walks', [
'template' => '../pages/attributes/default.html',
'filter'=> 'slug', 
'match' => 'eq', 
'value' => perch_get('walkSlug'),
'count' => 1,
]);

Same deal, <perch:showall> displays the ID values I'm trying to use but they're not output by the template, only the markup is.

I'm using the following to set the values in php before any markup is output:

PerchSystem::set_vars([
    'domain'=>$domain,
    'url'=>$url,
    'sharing_image'=>$sharing_image,
    'sitename'=>$sitename,
    'twittername'=>$twitter,
    'title'=>$title,
    'description'=>$description,
    'og_title'=>$title,
    'og_description'=>$description,
    'og_author'=>$og_author,
]);

Seems like the problem is rescoping from <perch:pages> template tags?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you post your diagnostics?

Here you go - thanks!

Perch information
Perch Runway: 3.1.2
Production mode: Development (10)
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2)
DB driver: PDO
DB tables: perch3_backup_plans (0), perch3_backup_resources (0), perch3_backup_runs (0), perch3_categories (25), perch3_category_counts (0), perch3_category_sets (3), perch3_collection_index (14295), perch3_collection_items (323), perch3_collection_revisions (71), perch3_collections (3), perch3_content_index (379), perch3_content_items (54), perch3_content_locks (0), perch3_content_regions (23), perch3_menu_items (11), perch3_navigation (2), perch3_navigation_pages (7), perch3_page_routes (6), perch3_page_templates (15), perch3_pages (22), perch3_resource_log (2056), perch3_resource_tags (0), perch3_resources (563), perch3_resources_to_tags (0), perch3_settings (25), perch3_user_passwords (0), perch3_user_privileges (41), perch3_user_role_buckets (0), perch3_user_role_privileges (29), perch3_user_roles (3), perch3_users (2)
Users: 2
App runtimes:
<?php
    $apps_list = [ 
    ];
Editor plug-ins:
H1: cf88d922913906b1338a520d381d0713
L1: d4f8bc927eb06394f9bb53c793049066
F1: 3b606135b33e6a102526838f4152a807
headerColour: #7c9b9d
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
installedAt: 3.0.14
update_3.0.14: done
headerScheme: dark
update_runway_3.0.14: done
latest_version:
on_sale_version: 3.1.2
update_runway_3.1.1: done
dashboard: 1
sidebar_back_link: 1
hide_pwd_reset: 0
keyboardShortcuts: 0
siteOffline: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
content_skip_region_list: 1
assets_restrict_buckets: 0
logoPath: /perch/resources/bristlebird-logo.svg
update_runway_3.1.2: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /Users/adam/Sites/slievebloom.ie/site
PERCH_DB_USERNAME: root
PERCH_DB_DATABASE: slievebloom_db
PERCH_PRODUCTION_MODE: 10
PERCH_SCHEDULE_SECRET: qzdgBn1FRGrMQyg3
PERCH_DB_SERVER: localhost
PERCH_DB_PREFIX: perch3_
PERCH_EMAIL_FROM: adam@bristlebird.com
PERCH_EMAIL_FROM_NAME: Adam Green
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/adam/Sites/slievebloom.ie/site/perch
PERCH_CORE: /Users/adam/Sites/slievebloom.ie/site/perch/core
PERCH_RESFILEPATH: /Users/adam/Sites/slievebloom.ie/site/perch/resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_TZ: UTC
PERCH_RWD: 1
PERCH_SSL: 1
PERCH_PRIV_ASSIST: 1
PERCH_TEMPLATE_FILTERS: 1
PERCH_GMAPS_API_KEY: AIzaSyBhau9dca_F3F9Z-_Cve5q7OTHmQSdM4ww
PERCH_DEBUG: 1
PERCH_RUNWAY: 1
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_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_ASSET_VERSION: 6738d5d5f5664f7c5e34
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/adam/Sites/slievebloom.ie/site/perch/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_XHTML_MARKUP:
PERCH_HTML_ENTITIES:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_DEFAULT_BUCKET: default
PERCH_TRANSLATION_ASSIST:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_CUSTOM_EDITOR_CONFIGS:
PERCH_ENABLE_EXIF: 1
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: markdown
Hosting settings
PHP: 7.0.30
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
MySQL server: 5.7.21
Free disk space: 163.82 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imap, gettext, mcrypt, pgsql, pdo_pgsql
GD: Yes
ImageMagick: No
PHP max upload size: 256M
PHP max form post size: 256M
PHP memory limit: 512M
Total max uploadable file size: 256M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PHP_FCGI_CHILDREN: 4
PWD: /Applications/MAMP/fcgi-bin
PHP_FCGI_MAX_REQUESTS: 200
__CF_USER_TEXT_ENCODING: 0x46:0:0
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.30.fcgi
ORIG_PATH_TRANSLATED: /Users/adam/Sites/slievebloom.ie/site/perch/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /perch/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.30.fcgi
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /perch/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 57797
SCRIPT_FILENAME: /Users/adam/Sites/slievebloom.ie/site/perch/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/adam/Sites/slievebloom.ie/site
REMOTE_ADDR: ::1
SERVER_PORT: 443
SERVER_ADDR: ::1
SERVER_NAME: slievebloom.test
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: cmsa=1; PHPSESSID=e125e04a7f3659ad2de44c9dd0e328af
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.9
HTTP_ACCEPT_ENCODING: gzip, deflate, br
HTTP_REFERER: https://slievebloom.test/perch/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CACHE_CONTROL: no-cache
HTTP_PRAGMA: no-cache
HTTP_CONNECTION: keep-alive
HTTP_HOST: slievebloom.test
SSL_TLS_SNI: slievebloom.test
HTTPS: on
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
REDIRECT_SSL_SESSION_ID: 64CA09067EA38EFB91C150583441B32638316EF1129161F5F7076A734F66512E
REDIRECT_SSL_SERVER_A_SIG: sha256WithRSAEncryption
REDIRECT_SSL_SERVER_A_KEY: rsaEncryption
REDIRECT_SSL_SERVER_I_DN: /C=ie/CN=slievebloom.test
REDIRECT_SSL_SERVER_S_DN: /C=ie/CN=slievebloom.test
REDIRECT_SSL_SERVER_V_END: Feb 19 18:05:31 2019 GMT
REDIRECT_SSL_SERVER_V_START: Feb 19 18:05:31 2018 GMT
REDIRECT_SSL_SERVER_M_SERIAL: 8C0B739B69B249D3
REDIRECT_SSL_SERVER_M_VERSION: 3
REDIRECT_SSL_CLIENT_VERIFY: NONE
REDIRECT_SSL_CIPHER_ALGKEYSIZE: 128
REDIRECT_SSL_CIPHER_USEKEYSIZE: 128
REDIRECT_SSL_CIPHER_EXPORT: false
REDIRECT_SSL_CIPHER: ECDHE-RSA-AES128-GCM-SHA256
REDIRECT_SSL_COMPRESS_METHOD: NULL
REDIRECT_SSL_SECURE_RENEG: true
REDIRECT_SSL_PROTOCOL: TLSv1.2
REDIRECT_SSL_VERSION_LIBRARY: OpenSSL/1.0.2o
REDIRECT_SSL_VERSION_INTERFACE: mod_ssl/2.2.34
REDIRECT_SSL_SERVER_I_DN_CN: slievebloom.test
REDIRECT_SSL_SERVER_I_DN_C: ie
REDIRECT_SSL_SERVER_S_DN_CN: slievebloom.test
REDIRECT_SSL_SERVER_S_DN_C: ie
REDIRECT_SSL_TLS_SNI: slievebloom.test
REDIRECT_HTTPS: on
REDIRECT_proto: https
FCGI_ROLE: RESPONDER
PHP_SELF: /perch/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1538480675.37
REQUEST_TIME: 1538480675
argc: 1
Drew McLellan

Drew McLellan 2638 points
Perch Support

Was this an issue with template nesting depth?

No, without any nested templates it's still not working. Tried the following also as a variation of the above:

perch_collection('Walks', [
    'template' => 'collections/_meta.html',
    'filter'=> 'slug', 
    'match' => 'eq', 
    'value' => perch_get('walkSlug'),
    'count' => 1,
]);

_meta.html:

<perch:template path="pages/attributes/seo" rescope="parent">
<perch:template path="pages/attributes/facebook" rescope="parent">
<perch:template path="pages/attributes/twitter" rescope="parent">

<perch:showall> displaying the correct ID values in template as expected. Any further suggestions ideas as to what the issue might be here?

Thanks again!