public function listing($contenttype)
{
// First candidate: Global config.yml
$template = $this->app['config']->get('general/listing_template');
// Second candidate: Theme-specific config.yml file.
if ($this->app['config']->get('theme/listing_template')) {
$template = $this->app['config']->get('theme/listing_template');
}
// Third candidate: a template with the same filename as the name of
// the contenttype.
if ($this->app['render']->hasTemplate($contenttype['slug'] . '.twig')) {
$template = $contenttype['slug'] . '.twig';
}
// Fourth candidate: defined specificaly in the contenttype.
if (!empty($contenttype['listing_template'])) {
$template = $contenttype['listing_template'];
}
return $template;
}