Skip to content
  1. Extras
  2. ms2Gallery
  3. Examples
  4. Bootstrap3 Slider

Bootstrap3 Slider

Image output in ms2Gallery in a typical slider Bootstrap3 with help of pdoResources.

Call on the page

A ready-made standard call from the example on the site Bootstrap3.

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
      &tplFirst=`@INLINE <div class="item active">
        <img src="[[+url]]" alt="">
        <div class="carousel-caption">
      &tpl=`@INLINE <div class="item">
        <img src="[[+url]]" alt="">
        <div class="carousel-caption">
      &where=`{"msResourceFile.resource_id":[[*id]], "msResourceFile.path:LIKE":"%360x270%"}`

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>

By default the snippet shows images of the current resource in 360x270 quality, but you can indicate your own selection criteria in parameter &where=``:

&where=`{"msResourceFile.resource_id:IN":[1,2,3,4,5]", "msResourceFile.parent":0}`

It will show big images from the resources 1 to 5.

Snippet GenerateIndicators

Snippet accepts the general quantity of slider's images and generated indicators for switching:

if (empty($tpl)) {
  $tpl = '@INLINE <li data-target="#carousel-example-generic" data-slide-to="[[+idx]]" [[+class]]></li>';

if (empty($input)) {
  return '';

$pdo = $modx->getService('pdoTools');
$output = '';
for ($i = 0; $i < $input; $i++) {
  $data = array(
    'class' => $i === 0 ? 'class="active"' : '',
    'idx' => $i
  $output .= $pdo->getChunk($tpl, $data);

if (!empty($toPlaceholder)) {
  $modx->setPlaceholder($toPlaceholder, $output);
else {
  return $output;

You can transmit &tpl and &toPlaceholder if you need to.

Work logic

pdoResources shows images by the indicated conditions and puts out a placeholder with their general quantity on the page. It is in its turn accepted by snippet GenerateIndicators, which generates indicators for switching on the images.

The generation snippet should be called for after pdoResources, so that there already is a number in placeholder[[]]. The indicators should be shown before the images, that is why the snippet puts them in placeholder [[+indicators]].