I'm using a number of custom layouts that use templates from this module, which work, like so:
mytheme_basic:
label: Basic
description: 'Standard layout for most content.'
category: MyTheme
class: '\Drupal\bootstrap_layouts\Plugin\Layout\BootstrapLayoutsBase'
type: partial
path: ../../modules/contrib/bootstrap_layouts/
template: templates/3.0.0/bs-2col-stacked
library: mytheme/layouts
regions:
top:
label: 'Top'
classes:
- col-sm-12
left:
label: 'Left'
classes:
- col-sm
right:
label: 'Right'
classes:
- col-sm-4
bottom:
label: 'Bottom'
classes:
- col-sm-12
But when I create a custom template for one of these layouts, I get "Fatal error: Call to a member function id() on null in /code/modules/contrib/bootstrap_layouts/bootstrap_layouts.module on line 83". It's trying to reference the layout at $variable['layout'] but it's no longer there for some reason. This is the layout causing that error:
mytheme_list_item:
label: List Item
description: 'Layout for display in a list.'
category: MyTheme
class: '\Drupal\bootstrap_layouts\Plugin\Layout\BootstrapLayoutsBase'
type: partial
template: templates/layout/sprout-list-item
library: ma_bootstrap/sprouts-layouts
regions:
top:
label: 'Top'
classes:
- col-sm-12
left:
label: 'Left'
classes:
- col-sm
right:
label: 'Right'
classes:
- col-sm
bottom:
label: 'Bottom'
classes:
- col-sm-12
Comments
Comment #2
dkosbob commentedThis patch solves it for me, by accessing the layout and settings one level deeper in the variable if it's not found. Still not sure about the cause of this.
Comment #3
markhalliwellThis is a core bug, see related issue for links.
Comment #4
npralhad commentedPatch worked for me too, thanks. I am trying to get the bootstrap layout overridden only for some specific content type, E.g. [article] --> [bs-1col-stacked--article.html.twig] but not able to get it working. Currently trying to get it done through layout hooks if possible.
Any assistance will be highly appreciated.
Comment #5
markhalliwellDon't hijack issues. I already explained that this is a core bug, not an issue with this project.
Comment #6
npralhad commentedHi Mark
Thanks for reply. My question was about - getting the bootstrap layout overridden only for some specific content type, E.g. [article] --> [bs-1col-stacked--article.html.twig]. Is that possible ?
Comment #7
markhalliwell