Forum

Thread tagged as: Problem, Runway

perch:related not working for a specific collection

Hi,

For some reason when using perch:related with a specific collection it's not retrieving the content even though other collections used in the same template are working fine with perch:related

Here is my 'Model' collection (template model.html)

<perch:related id="make" collection="Make" label="Make">
<perch:content id="make" type="text" label="Make Order" />
</perch:related>

<perch:content id="model" type="text" label="Car Model" required="true" title="true" help="e.g. A1, A3 Sportback, 2 Series, 3 Series etc" />
<img src="<perch:content type="image" id="modelpic" label="Model Photo" width="512" height="384" crop="true" bucket="cars" />" alt="<perch:content type="text" id="modelpicalt" label="SEO/Listing Title" placeholder="e.g Audi A1 Leasing" required="true" />" />
<perch:content id="slug" type="slug" for="model" editable="true" indelible="true" label="Slug" />
<perch:content id="modeldesc" type="textarea" label="Model Description" html="true" editor="ckeditor" />


<perch:related id="deal" collection="Deal" label="Deals">
<perch:content id="dealtitle" type="text" label="Deals" />
</perch:related>

The top perch:related tag for the "Make" collection is working fine and I get a list of makes to select from when creating/edit a model.

However, the bottom perch:related tag for Deals is not showing me a list of deals from the Deal collection.

The Deal Collection (template deals.html) is as follows:

<perch:related id="make" collection="Make" label="Make">
<perch:content id="make" type="text" label="Make Order" />
</perch:related>
<perch:related id="model" collection="Model" label="Model">
<perch:content id="model" type="text" label="Model" required="true" />
</perch:related>

<perch:content type="text" id="dealtitle" label="Deal Title" help="e.g Audi A1 1.6 TDI S Line S Tronic" size="xl" required="true" />
<perch:content id="slug" type="slug" for="dealtitle" editable="true" indelible="true" label="Deal Slug" />
<perch:content id="business" type="text" label="Business Price" help="only enter value, do not enter £ sign or plus VAT e.g. 230.68" size="m" />
<perch:content id="personal" type="text" label="Personal Price" help="only enter value, do not enter £ sign or inc VAT e.g. 230.68" size="m" />
<perch:content id="profile" type="text" label="Payment Profile" help="enter as 6+35 etc" size="s" />
<perch:content id="mileage" type="text" label="Annual Mileage" help="enter numeric value only e.g. 8000" size="s" />
<perch:content id="dealdesc" type="textarea" label="Deal Description" html="true" editor="ckeditor" />
<perch:content id="showdeal" type="checkbox" label="Show Deal on Home page" value="1" suppress="true" />

Here is a screenshot of the Model collection (template model.html) which shows the 'Deals' field in focus but no list appearing https://www.evernote.com/l/Ai_JGnrzF4VP45kYep0rc3mS8MMUSk7KHOI

My diagnostics report is as follows:

PERCH INFORMATION

Perch Runway: 2.8.29
Production mode: Production (100)
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_blog (5.0), collection_7 (2.8.29), perch_forms (1.8.3), collection_5 (2.8.29), collection_6 (2.8.29)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (0), perch2_blog_posts (0), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (0), perch2_category_counts (0), perch2_category_sets (1), perch2_collection_index (1925), perch2_collection_items (129), perch2_collection_revisions (27), perch2_collections (3), perch2_content_index (216), perch2_content_items (24), perch2_content_regions (6), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (9), perch2_page_templates (8), perch2_pages (6), perch2_resource_log (295), perch2_resource_tags (0), perch2_resources (66), perch2_resources_to_tags (0), perch2_settings (24), perch2_user_passwords (0), perch2_user_privileges (34), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: ckeditor, markitup
H1: 514e4c76d460455a6a7b6bec32bd6c6c
L1: 95ef83c36f3f16c3f0fe678b5c0b7d01
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #da1030
content_singlePageEdit: 1
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.29: done
logoPath: /site_admin/resources/website-logo.png
headerScheme: dark
update_runway_2.8.29: done
latest_version: 2.8.15
on_sale_version: 2.8.32
perch_blog_update: 5.0.1
perch_blog_post_url: /blog/post.php?s={postSlug}
perch_blog_site_name: Car Leasing Blog by Vehicle Lease Management
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 1
dashboard: 1
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_blog_comment_notify: 0
helpURL:
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SCHEDULE_SECRET: sUs3TTT0rrFGz3x9
PERCH_SITEPATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev
PERCH_DB_USERNAME: root
PERCH_DB_SERVER: localhost
PERCH_DB_PORT: 8889
PERCH_DB_DATABASE: vlm_dev
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: neil@so53.co.uk
PERCH_EMAIL_FROM_NAME: Neil Duddridge
PERCH_LOGINPATH: /site_admin
PERCH_PATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin
PERCH_CORE: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core
PERCH_RESFILEPATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/assets
PERCH_RESPATH: /assets
PERCH_DEBUG: 1
PERCH_HTML5: 1
PERCH_TZ: Europe/London
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_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 7.0.10
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
MySQL server: 5.6.28
Free disk space: 93.48 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: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
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: 0x1F5:0x0:0x2
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.10.fcgi
ORIG_PATH_TRANSLATED: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /site_admin/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.10.fcgi
SCRIPT_NAME: /site_admin/core/settings/diagnostics/index.php
REQUEST_URI: /site_admin/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /site_admin/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 54328
SCRIPT_FILENAME: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev/site_admin/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/neilduddridge/Google Drive/SO53Projects/VLM/dev
REMOTE_ADDR: ::1
SERVER_PORT: 8888
SERVER_ADDR: ::1
SERVER_NAME: vlm.dev
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: cmssb=0; cmsa=1; PHPSESSID=ef8c4c5246c2e2562c136646ecd3db81
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://vlm.dev:8888/site_admin/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: keep-alive
HTTP_HOST: vlm.dev:8888
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
FCGI_ROLE: RESPONDER
PHP_SELF: /site_admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1477609373.08
REQUEST_TIME: 1477609373
argc: 1
Neil Duddridge

Neil Duddridge 1 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Are you seeing any errors if you enable debug?

Also you are a little out of date so updating would be the first thing to try.

Good point, let me update the core first.

I will post debug after if problem persists.

Thanks.

I've updated the core,

Here's the debug message on the Model collection which has the perch:related tags for Deal collection that is not showing list of deals

Debug Message
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='a7d875b931cd5bab47e1d3169aa5bf24' LIMIT 1
UPDATE perch2_users SET userHash='e505a8e571a81da4981d633e6484c79a' WHERE userID='1'
[39] SELECT p.privKey FROM perch2_user_privileges p
[25] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
[3] SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
[1] SELECT * FROM perch2_collections WHERE collectionID=6 LIMIT 1
[1] SELECT ci.*, r.itemOrder, IF(r.itemLatestRev>r.itemRev,1,0) AS _has_draft FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='6' AND ci.itemRev=r.itemLatestRev AND ci.itemID=9 ORDER BY r.itemOrder ASC
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='6' AND ci.itemRev=r.itemRev AND ci.itemID=9
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='6' AND ci.itemRev=r.itemRev AND r.itemOrder > '1001' ORDER BY r.itemOrder LIMIT 1
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='6' AND ci.itemRev=r.itemRev AND r.itemOrder < '1001' ORDER BY r.itemOrder DESC LIMIT 1
Using template: /templates/content/model.html
Form not posted or did not validate
[1] SELECT itemRev, itemLatestRev FROM perch2_collection_revisions WHERE collectionID=6 AND itemID=9 LIMIT 1
[1] SELECT * FROM perch2_collections WHERE collectionKey='Make' LIMIT 1
[10] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='5' AND ci.itemRev=r.itemRev ORDER BY r.itemOrder ASC
[1] SELECT * FROM perch2_collections WHERE collectionKey='Deal' LIMIT 1
[4] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='7' AND ci.itemRev=r.itemRev ORDER BY r.itemOrder ASC
Queries: 16
Memory: 3.2593
Drew McLellan

Drew McLellan 2638 points
Perch Support

The collection attribute takes a slug, not a label, so this:

<perch:related id="make" collection="Make" label="Make">

should probably be:

<perch:related id="make" collection="make" label="Make">

Hi Drew,

That makes no difference. Just so you know the collection="Make" was and is working fine. I changed it to collection="make" and that still worked also.

It's the perch:related for the Deal collection that's my problem as per the template below. (I had also changed it to collection="deal" but didn't work)

<perch:related id="make" collection="Make" label="Make">
<perch:content id="make" type="text" label="Make Order" />
</perch:related>

<perch:content id="model" type="text" label="Car Model" required="true" title="true" help="e.g. A1, A3 Sportback, 2 Series, 3 Series etc" />
<img src="<perch:content type="image" id="modelpic" label="Model Photo" width="512" height="384" crop="true" bucket="cars" />" alt="<perch:content type="text" id="modelpicalt" label="SEO/Listing Title" placeholder="e.g Audi A1 Leasing" required="true" />" />
<perch:content id="slug" type="slug" for="model" editable="true" indelible="true" label="Slug" />
<perch:content id="modeldesc" type="textarea" label="Model Description" html="true" editor="ckeditor" />


<perch:related id="deal" collection="Deal" label="Deals">
<perch:content id="dealtitle" type="text" label="Deals" />
</perch:related>

Here's a screenshot of the perch2_collections table in the database, if that helps.

https://www.evernote.com/l/Ai8RRmBvjDBO7bXyPbR76FPTUOTN9CRi-RY

Drew McLellan

Drew McLellan 2638 points
Perch Support

Sorry, you're right, my brain's not working.

Make sure you have title="true" set on something in your Deals collection master template.

I know the feeling :)

That worked!

Thanks.