The Gravstrap Well shortcode handles the Bootstrap Well component. Here is a live example:

The well shortcode, shown above, is defined by the following definition:

[g-well name=well1]
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
[/g-well]

Shortcode parameters

The [bootstrap-collapse] shortcode has some optional parameters:

  • name - defines an unique component name.
  • size - defines the well size and could be one of the following values: small|large.
  • attributes - defines extra attributes you can add to your shortcode. Attributes is a string of HTML key:value tokens, separated by commas. A valid attributes value is attributes=class:myclass, rel:my-rel".

Render the well component using the template

The well component can also be dynamically filled with data provided by a json file or fetched from a database. You will provide an array similar to the following one:

$well = array(
    'name' => 'pageheader1',
    'size' => 'large',            
    'attributes' => 'class:my-class,rel:my-rel',
    'content' => 'Cras mattis consectetur purus sit amet fermentum.',
);

$this->grav['twig']->twig_vars['well'] = $well;

then in your template you will render the well as follows:

{% include 'bootstrap/well.html.twig' with well %}

Please note that the provide content is raw: it's up to you to provide a formatted one.

Next Post