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, Shop

Collection items in Shop product

Hello, I have no success showing collection items in a products template. My collection holds testimonials with a "text" and a "name" field

<div class="socialproof socialproof__base">
    <div class="socialproof__texto">
        <perch:content id="text" type="textarea" size="s" label="Texto" />  
    </div>
    <div class="socialproof__nombre">
        <perch:content id="name" type="text" label="Nombre" title="true"/>
    </div>
</div>

in my product.html I'm doing this:

<perch:before>
    <ul class="testimonios__list">
</perch:before>
    <li class="testimonio__item">
        <perch:related id="testimonio" collection="Social Proof" label="Testimonio" scope-parent="true">
        <p><perch:content id="parent.name" /></p>
        </perch:related>
        </li>
<perch:after>
</ul>
</perch:after>

but the field I create stays empty.

Can you see what I'm doing wrong?

Thanks a lot

Proko Mountrichas

Proko Mountrichas 3 points

  • 2 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Have you enabled debug so you can see what is being returned? That would be the first step.

I did and don't think there's anything useful there

Debug Message
[28] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
Matched route: servicio/[slug:s]
Using master page: /templates/pages/servicio.php
Page arguments:
Array
(
    [0] => /servicio/deco-coaching-para-se-fe-sdc001
    [s] => deco-coaching-para-se-fe-sdc001
    [1] => deco-coaching-para-se-fe-sdc001
)
[1] SELECT * FROM perch2_pages WHERE pagePath='/servicios/servicio' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=165
[1] SELECT * FROM perch2_shop_cart WHERE cartID=165
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/facebook.html
[7] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/servicios/servicio' OR regionPage='*' ORDER BY regionPage DESC
[4] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/servicios/servicio' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-003-001', '000-003', '000') ORDER BY pageTreePosition DESC
[4] Using template: /templates/navigation/item.html
Using template: /templates/search/menu_search.html
[1] SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='deco-coaching-para-se-fe-sdc001')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey ) as tbl WHERE (productDeleted IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
[38] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] Using template: /templates/shop/products/product.html
Using sub-template: /templates/shop/products/servicio/_service_top_image.html
Rescoping to perch:shop
Using sub-template: /templates/content/textonimage.html
Using sub-template: /templates/shop/products/servicio/listwithtitle.html
[5] Using sub-template: /templates/shop/products/servicio/listwithimage.html
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=44 LIMIT 1
Using template: /templates/mailchimp/forms/subscribe.html
[1] SELECT groupID FROM perch2_navigation WHERE groupSlug='footer-links' LIMIT 1
[2] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
[0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/servicios/servicio' LIMIT 1
[2] Using template: /templates/navigation/footer-links.html
Drew McLellan

Drew McLellan 2637 points
Perch Support

Does the field appear on the edit form?

It does but when clicking on the input nothing happens. I saw in your video on relationships that it should display the available collection fields like a "select" field. In my case I just get a text input and whatever I type inside I get "No results match".

Drew McLellan

Drew McLellan 2637 points
Perch Support

Just to establish what is working and what isn't - are normal relationships between collections working as expected?

I created a 2nd Collection to test and realised that normal relationships don't work either!

The new collection template is

<h1><perch:content id="text" type="text" label="Título" required="true" title="true" /></h1>
<perch:related id="sp" collection="Social Proof" label="SP">
  <p>
      <perch:content id="name" /> <perch:content id="text" />
  </p>
</perch:related>

and the debug from this collection's admin page:

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='026d1f967b827b143fbf7862c83ed77a' LIMIT 1
UPDATE perch2_users SET userHash='35373bf568adb8c1698a043c43a42b50' WHERE userID='1'
[81] SELECT p.privKey FROM perch2_user_privileges p
[38] 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
[nil] SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
[1] SELECT * FROM perch2_collections WHERE collectionID=5 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='5' AND ci.itemRev=r.itemLatestRev AND ci.itemID=10 ORDER BY r.itemOrder ASC
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='5' AND ci.itemRev=r.itemRev AND ci.itemID=10
[1] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='5' AND ci.itemRev=r.itemRev AND r.itemOrder > '1000' 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='5' AND ci.itemRev=r.itemRev AND r.itemOrder < '1000' ORDER BY r.itemOrder DESC LIMIT 1
Using template: /templates/content/heading.html
Form not posted or did not validate
[1] SELECT itemRev, itemLatestRev FROM perch2_collection_revisions WHERE collectionID=5 AND itemID=10 LIMIT 1
[1] SELECT * FROM perch2_collections WHERE collectionKey='Social Proof' LIMIT 1
[3] SELECT * FROM perch2_collection_items ci, perch2_collection_revisions r WHERE r.itemID=ci.itemID AND ci.collectionID='4' AND ci.itemRev=r.itemRev ORDER BY r.itemOrder ASC
Queries: 14
Memory: 4.5275

Must be something I'm doing wrong but can't find it :(

Apparently relationships don't like compound collection IDs. So "Social Proof" didn't work while "Testimonials" did. Maybe it's worth to add to the docs if designed to work like this.

Drew McLellan

Drew McLellan 2637 points
Perch Support

That's not intended - we'll take a look at it.