I'm using ezplatform and trying to figure out how to automatically share common cms content to all pages without writing a separate controller for each view.
This is a simple extract from the yml file:
root_folder:
controller: "AppBundle:Homepage:homepage"
match:
Id\Location: 58
article_container:
controller: "AppBundle:ArticleContainer:articleContainerChildren"
match:
Identifier\ContentType: "article_container"
article_one_column:
template: "full/article_one_column.html.twig"
match:
Identifier\ContentType: "article_one_column"
These are three simple matches to there own custom controllers, with the exception of the last.
The first two matches hit a controller which extends a base controller. Within the base controller we have a standard render function which is called like this:
return $this->render(
'full/article_container.html.twig',
[
'location' => $location,
'content' => $currentContent,
'articles' => $articles,
'articleLocations' => $locations,
]
);
The said render function looks like this:
$parameters = array_merge($parameters, [
'main_navi' => $navigation,
'mega_navi_data' => $navigation,
'quotes' => $contentRenderer->getQuotesData(),
'featured_articles' => $contentRenderer->getFeaturedArticles(),
'contact_form' => $this->getContactForm(),
]);
return parent::render($view, $parameters, $response);
As you can see we simply merge the original params with some common data that all pages need. This data is used for the "maga navi" and the footer content.
The problem is now that when we try to load a article_one_column
page,
as this is not using a custom controller it therefore doesn't load the common data
required for the header and footer which results in an twig error.
QUESTION: How can we deliver common content to all routes without writing a custom controller for each data type?