Skip to content

Instantly share code, notes, and snippets.

@vdrnn

vdrnn/Page.php Secret

Created May 24, 2020
Embed
What would you like to do?
Page.php Controller
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
class Page extends Controller
{
use ContentModules\Hero;
use ContentModules\LargeBullets;
use ContentModules\RichText;
use ContentModules\Publications;
use ContentModules\PageTeaser;
use ContentModules\JobsOverview;
use ContentModules\TeamMembers;
use ContentModules\TeamOverview;
use ContentModules\CalendarOverview;
use ContentModules\CalendarEntries;
protected $acf = false;
public function content_modules()
{
$acfData = [];
if( have_rows('content_modules') ):
while ( have_rows('content_modules') ) : the_row();
$layout = get_row_layout();
if($layout == 'cm-hero') {
$data = $this->get_hero_data();
$template = 'hero';
} elseif ($layout == 'cm-large_bullets') {
$data = $this->get_large_bullets_data();
$template = 'large-bullets';
} elseif ($layout == 'cm-rich_text') {
$data = $this->get_rich_text_data();
$template = 'rich-text';
} elseif ($layout == 'cm-publications') {
$data = $this->get_publications_data();
$template = 'publications';
} elseif ($layout == 'cm-page_teaser') {
$data = $this->get_page_teaser_data();
$template = 'page-teaser';
} elseif ($layout == 'cm-jobs_overview') {
$data = $this->get_jobs_overview_data();
$template = 'jobs-overview';
} elseif ($layout == 'cm-team_members') {
$data = $this->get_team_members_data();
$template = 'team-members';
} elseif ($layout == 'cm-team_overview') {
$data = [];
$template = 'team-overview';
} elseif ($layout == 'cm-calendar_overview') {
$data = $this->get_calendar_overview_data();
$template = 'calendar-overview';
}elseif ($layout == 'cm-calendar_entries') {
$data = $this->get_calendar_entries_data();
$template = 'calendar-entries';
}
$acfData[] = [
'template' => $template,
'data' => $data,
];
endwhile;
endif;
return $acfData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment