Forum

Thread tagged as: Question, Discussion

Dataselect/pagelist field type that pulls in blog posts

I have a region that has some custom content but also needs to pull in select blog posts (similar to perch:related). What is the best way to achieve this?

Brad Cerasani

Brad Cerasani 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There isn't currently a field type for that, but it would be fairly easy to put together. Very much like the albumlist field type that comes with Gallery.

I did use https://github.com/shb/perch2-fieldtypes-customlist once which lets you get data from apps, not sure if this would work in your case or if it is something similar to what you are looking for.

Thanks for the prompt reply Drew + Liam.

I can use the customlist fieldtype Liam linked to above, but it will only pull one field at a time and I need the ability to pull multiple. Is it possible to modify this fieldtype to pull multiple fields?

Modifying the albumlist fieldtype is a little over my (very basic) PHP knowledge for the tight timeline I'm on.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Would you need to pull many fields? Surely it'd be enough to get the postID, then you could query the rest as you use it.

No, not many fields - perhaps the title, slug, and excerpt. How would I go about getting the postID and querying the rest?

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you can get the postID or postSlug (via a modified version of albumlist or that third party option) then you can use skip-template to get in back on the page. Once you have that, you can pass it to perch_blog_custom() to get the rest and pass it back into the template.

I don't think that will work with my intended usage - I need it to return the actual field content like perch:related

Drew McLellan

Drew McLellan 2638 points
Perch Support

The result would be the same, but ok. That's the best I've got.

Correct me if I'm wrong - this is for a repeating region; some entries of this region will have original content, some will have content pulled from blog posts. Knowing this, having it fetch the other blog post data won't work how I need it to, correct?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think it would. You could handle it in the each callback.