I am working with D8, and don't usually do themeing, so I am stuck on a problem.
I have a custom route in a custom module that calls a method checkinConfirmation() on a controller.
Inside that controller, I have this:
public function checkinConfirmation() {
$output['items'] = [
'#type' => 'fieldset',
'#title' => t('Checked in items'),
];
$output['items']['name'] = [
'#prefix' => '<h2>',
'#suffix' => '</h2>',
'#markup' => t('Name'),
];
$output['#theme'] = 'circulation_confirmation';
$output['#output'] = $output;
return $output;
}
and inside of my theme, I have this inside of hook_theme()
public function mytheme_theme() {
$theme['circulation_confirmation'] = [
'template' => 'page/circulation--confirmation',
'variables' => [
'output' => [],
],
];
}
In my template, I have a {{ output }}
variable to print the rendered output provided from $output. The problem is though, I do not get the items in the template, and I cannot figure out why. The template is getting pulled in, as the wrapper in the template file is being applied on the page, and the main container is the width it should be.
In using this instead (in the controller):
return [
'#theme' => 'circulation_confirmation',
'#output' => $output,
];
I at least get the data, but it doesn't appear to be using the template I provided as the wrapper is now gone and the main container is full width instead of the width it should be.
I don't usually do themeing or templating, and when I do it's usually forms so I can just pass it 'render element' => 'form', to get it to pass the form items to the theme. I am not sure what I am doing wrong.
Please help?