Skip to main content
improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

As far I understood you want render this peace ofthe following code in multiple <divs>.

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    // Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace ofReplace it with the following code on this:.

   foreach($items as $item_key => $item) {
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
  
     $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':Or use the following code.

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:Alternatively, you can use the following code.

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }

P.S. readYou can find more information about Render Arraysrendering arrays  , also some elements described atand Form API.

As far I understood you want render this peace of code

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    //Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace of code on this:

   foreach($items as $item_key => $item){
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
      $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }

P.S. read about Render Arrays  , also some elements described at Form API

As far I understood you want render the following code in multiple <divs>.

$page_array['photo_gallery_arguments'] = array(
  '#title' => t('All photos from ever'),
  '#items' => $items,
  // Theme hook with suggestion.  
  '#theme' => 'item_list',
  '#type' => 'div',
);

Replace it with the following code.

   foreach($items as $item_key => $item) {
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' => 'container',
       '#attributes' => array(
         'class' => array(
           'my-class-' . $item_key,
         ),
       ),
     );
 
     $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
       '#type' => 'markup',
       '#markup' => $item,
     );
   }

Or use the following code.

   foreach($items as $item_key => $item){
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' => 'markup',
       '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
     );
   }

Alternatively, you can use the following code.

   foreach($items as $item_key => $item){
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' => 'item',
       '#markup' => $item,
     );
   }

You can find more information about rendering arrays, and Form API.

added 213 characters in body
Source Link
milkovsky
  • 5.4k
  • 37
  • 59

As far I understood you want render this peace of code

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    //Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace of code on this:

   foreach($items as $item_key => $item){
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
      $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }

P.S. read about Render Arrays , also some elements described at Form API

As far I understood you want render this peace of code

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    //Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace of code on this:

   foreach($items as $item_key => $item){
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
      $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }

As far I understood you want render this peace of code

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    //Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace of code on this:

   foreach($items as $item_key => $item){
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
      $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }

P.S. read about Render Arrays , also some elements described at Form API

Source Link
milkovsky
  • 5.4k
  • 37
  • 59

As far I understood you want render this peace of code

$page_array['photo_gallery_arguments'] = array(
    '#title' => t('All photos from ever'),
    '#items' => $items,
    //Theme hook with suggestion.  
    '#theme' => 'item_list',
    '#type' => 'div',
  );

in series of divs ... So change those peace of code on this:

   foreach($items as $item_key => $item){
      $page_array['photo_gallery_arguments'][$item_key] = array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => array(
            'my-class-' . $item_key,
          ),
        ),
      );
      $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
        '#type' => 'markup',
        '#markup' => $item,
      );
   }

OR another variant with 'markup':

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'markup',
            '#markup' => '<div class="my-class-"' . $item_key . '>' . $item . '</div>',
          );
    }

OR another variant - divs without classes:

   foreach($items as $item_key => $item){
          $page_array['photo_gallery_arguments'][$item_key] = array(
            '#type' => 'item',
            '#markup' => $item,
          );
    }