Forum

Thread tagged as: Question

Retrieving content from multiple regions

I have a subpages that my client can create that produce two regions (overview, documents). 'Overview" region contains name and description of duties, "Documents" region is a list of files by date (sometimes over 100 files, hence why its not included directly in the Overview region to manage easier)

I would like to pull in the page name that both these regions appear under from navigation or if thats not possible from the "overview region" group-name ID.

Visual of what I'm trying to do: meetings-table

Seth Girardin

Seth Girardin 0 points

  • 5 years ago

I understand the to retrieve content from multiple regions you have to sort by a common ID, and it needs to also put them in the correct order.

But I'm not sure I even need to involve the "overview" region if I can get the PageTitle another way, much like special ID value _page works for linking purposes.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not completely clear on what you're now asking! Sorry.

Are you saying you can use _page?

No problem. Hard to explain as well. I'll start again.

My client can create new groups of people themselves, these new pages create two regions. One region is a "main content" area for text details of group and the other is "meetings" region which is basically a list of dates with two files attached.

I have a page called "Meetings" which pulls all the information:

perch_content_custom(array('Main content', 'Meetings'), array(
    'page'=>'/town-government/boards-and-committees/*',
    'template'=>'/meetings/meeting_minutes.html',
    'sort' => 'meeting_date',
    'sort-order' => 'DESC',
    'filter' => 'meeting_date',
    'match' => 'lte',
    'value' => date('Y-m-d 23:59:59')

    ));

How its structured:

meetings1

Title I would like to get:

meetings2

Drew McLellan

Drew McLellan 2638 points
Perch Support

So for each item you want to display the title of the page it came from?

Yes, exactly.

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content_custom(array('Main content', 'Meetings'), array(
    'page'=>'/town-government/boards-and-committees/*',
    'template'=>'/meetings/meeting_minutes.html',
    'sort' => 'meeting_date',
    'sort-order' => 'DESC',
    'filter' => 'meeting_date',
    'match' => 'lte',
    'value' => date('Y-m-d 23:59:59')
    'each' => function($item) {
        if (isset($item['_pageID'])) {
            $Content = PerchContent::fetch();
            $Page = $Content->get_page_by_id($item['_pageID']);
            if ($Page) {
                $item['_page_title'] = $Page->pageTitle();
            }
        }
        return $item;
    }
 ));

Then in your template you can use id="_page_title"

Thanks so much. I learned a lot from your solution and couldn't have done it otherwise. :)

One thing missing to have it work was it also needed comma after the 'value' => date('Y-m-d 23:59:59'), line.