Forum

Thread tagged as: Question, Problem

Perch's Page Attributes functions don't work with 'two page list and detail' set...

Hello,

I've a basic 'two page list and detail' setup, almost identical to the example in Perch docs. I've a page on that the content 'lives', and another detail/simple page that is only used to display detail items. The latter doesn't even have any editable Perch regions, and as such is not listed in Perch admin.

I'd like to use perch_page_attributes() function for proper Open Graph tags, as suggested also in Perch docs. I've already done that with 'single page list and detail' setups several times, without a problem. The issue with the above setup is though, that Page Attribute functions don't work at all on – the above described – detail pages, they output nothing.

Before I dive in deeper, I'd like to know, if Page Attribute functions should work on pages without editable Perch regions, that are not listed in Perch admin? I've also checked Perch debug, which doesn't report any problems either.

No problem if not, then I'll probably add an editable region to the detail page, only to make this setup work. But as you see, in this case it'd make sense.

Thank you for your information in advance!

Márton Lente

Márton Lente 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Before I dive in deeper, I'd like to know, if Page Attribute functions should work on pages without editable Perch regions, that are not listed in Perch admin

How would you add page attributes to a page that Perch doesn't know about?

The page needs to exist in Perch before you can add any attributes. It doesn't need to have editable regions on it, but Perch needs to know it exists.

Thanks for the quick answer and explanation, of course it makes sense.

As I was about to pass all details as variables into the attribute template without touching the UI, I supposed it should work. As well it means you'll have extra pages in admin, you can't even hide, which is not very ideal.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Marton,

pass all details as variables into the attribute template without touching the UI

Is the details hard-coded or managed in a content region (multiple-item region)? If in a content region, you can use perch_content_custom() instead of perch_page_attributes().

Hello Hussein,

Thank you very much for the great tip! Since all details are present in the content region, it would have been the perfect solution for this specific case. :) I was just not thinking outside the box.

Yesterday I ended up creating 'placeholder' regions on detail pages, to let Perch know they exist – as Drew suggested. As well, I could manage to hide the 'helper' pages from Perch admin, with creating a simple UI plugin. I'll share the latter soon, maybe helps someone (I see this was asked several times here).

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yesterday I ended up creating 'placeholder' regions on detail pages, to let Perch know they exist – as Drew suggested

I didn't actually suggest that! But glad you got to your solution.

Sure, I only meant I let Perch know the pages existed, which was key to succeed. How I implemented this idea may not be too nice, but it works. :) Thank you for all your help!