You are here

function panels_bootstrap_render_items in Panels Bootstrap Layout Builder 7

Same name and namespace in other branches
  1. 7.3 plugins/layouts/bootstrap/bootstrap.inc \panels_bootstrap_render_items()

Render a piece of a bootstrap layout.

2 calls to panels_bootstrap_render_items()
theme_panels_bootstrap in plugins/layouts/bootstrap/bootstrap.inc
Draw the bootstrap layout.
theme_panels_bootstrap_admin in plugins/layouts/bootstrap/bootstrap.inc
Draw the bootstrap layout.

File

plugins/layouts/bootstrap/bootstrap.inc, line 436

Code

function panels_bootstrap_render_items($renderer, $list, $owner_id) {
  $output = '';
  $groups = array(
    'left' => '',
    'middle' => '',
    'right' => '',
  );
  $max = count($list) - 1;
  $prev = NULL;
  foreach ($list as $position => $id) {
    $item = $renderer->settings['items'][$id];
    $location = isset($renderer->positions[$id]) ? $renderer->positions[$id] : 'middle';
    switch ($item['type']) {
      case 'column':
        $content = panels_bootstrap_render_items($renderer, $item['children'], $renderer->base['column'] . '-' . $id);
        $groups[$location] .= panels_bootstrap_render_item($renderer, $item, $content, $id, $position, $max);
        break;
      case 'row':
        $content = panels_bootstrap_render_items($renderer, $item['children'], $renderer->base['row'] . '-' . $id);
        $groups[$location] .= panels_bootstrap_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
        break;
      case 'region':
        $content = isset($renderer->content[$id]) ? $renderer->content[$id] : " ";
        $groups[$location] .= panels_bootstrap_render_item($renderer, $item, $content, $id, $position, $max);
        break;
    }
    $prev = $id;
  }
  $group_count = count(array_filter($groups));

  // Render each group. We only render the group div if we're in admin mode
  // or if there are multiple groups.
  foreach ($groups as $position => $content) {
    if (!empty($content) || $renderer->admin) {
      if ($group_count > 1 || $renderer->admin) {
        $output .= $content;
      }
      else {
        $output .= $content;
      }
    }
  }
  return $output;
}