I am using the bootstraps layouts module with display suite to provide bootstrap styled layouts for a bootstrap themed Drupal 8 website.

Is there a way to create custom layouts based on the 'bootstrap layouts' and not the display suite built-in layouts? I am able to create custom variations of display suite templates, but trying the same thing with a bootstrap layout causes an 'unexpected error'

For reference I used this method to create a custom DS 'built-in' layout: Custom layouts with the Display Suite module

My process for creating a working custom display suite (non-bootstrap) custom layout:

  • created a MYTHEME.layouts.yml file in MYTHEME folder
  • opened \modules\ds\ds.layouts and copied one of the entries, say ds_1col for example, and pasted that into MYTHEME.layouts.yml
  • customized some items, like category, label/name
  • copied \modules\ds\templates\ds-1col.html.twig into MYTHEME\templates\ds\ and tweaked a bit to see if it works - just added a div with a background colour style
  • updated MYTHEME.layouts.yml with path to tweaked templates in my theme folder.
  • flushed caches, see my layout, and am able to apply it.
  • pages load with my custom layout.

My process for trying to create a custom bootstrap ds layout followed the exact same steps:

  • copy one of entries from \modules\bootstrap_layouts\bootstrap_layouts.layouts.yml into MYTHEME.layouts.yml
  • copied the matching template from \modules\bootstrap_layouts\templates\3.0.0\ into MYTHEME\templates\ds\
  • edited MYTHEME.layouts.yml to point to the template in my theme folder, changed category and name.
  • flushed caches, see my layout, and am able to apply it.
  • pages display "The website encountered an unexpected error. Please try again later." (Other pages/content types that don't use my custom ds layout and admin section still work fine)

Troubleshooting bit: If I remove "class: '\Drupal\bootstrap_layouts\Plugin\Layout\BootstrapLayoutsBase'" from my layouts.yml the page loads, though without any fields I placed using DS (just header, title, footer).

Not exactly familiar with debugging info, managed to get this. It is with the bootstraplayoutsbase in place. "mylayout-1" is the name of my layout.

The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on null in _bootstrap_layouts_preprocess_layout() (line 87 of modules\bootstrap_layouts\bootstrap_layouts.module).

_bootstrap_layouts_preprocess_layout(Array, 'mylayout_1', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('mylayout_1', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 43)
__TwigTemplate_fb2567a2d56d6244693eb445f60c9514cf4e8677dcb3a558998479f5787cac2d->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('modules/ds/templates/ds-entity-view.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('ds_entity_view', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  • Please list the exact steps you took to make the bootstrap layout and full debugging info for the error. Nov 10, 2017 at 5:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.