Error when looping through items

I am updating a theme from 1.5 to 2.1 and have replaced all the functions which have new names in this version. However, now I am getting an error message: Omeka_View_Exception
A current item variable has not been set to this view.
Here is the code that is throwing the error:

foreach ($collectionIDs as $collectionID) {
      $collection = get_record_by_id('collection',$collectionID);
      $collection_link = link_to_collection($collectionTitle, array(), 'show', $collection);
      $collection_items = get_records('Item',array('sort_field' => 'Dublin Core,Audience','sort_dir' => 'a','collection' => $collection['id']),9000);
      $num_of_collection_items = count($collection_items);
      $collection_item_list = array();

      while (loop('items')) {
        array_push($collection_item_list, array('thumb'=>item_square_thumbnail(array('alt'=>item('Dublin Core', 'Title'))),
                                                  'link'=>item_uri(), 'name'=>item('Dublin Core', 'Title')));

      echo '<h1 style="display: inline;">' .$collection_link. '</h1>';
      echo '<hr style="visibility: hidden; margin-top: 2px; margin-bottom: 4px;" />';
      echo '<ul id="collection'.$div_counter.'" class="slider">';

      for ($i=0; $i < $num_of_collection_items; $i++) {
        echo '
        echo '<a href="'.$collection_item_list[$i]['link'].'" rel="tooltip" title="'.$collection_item_list[$i]['name'].'">'.$collection_item_list[$i]['thumb'].'</a>';
        echo '</li>

      echo '';
      echo '<hr style="visibility: hidden; margin-top: 3px; margin-bottom: 3px;" />';


Specifically "get_current_record('item');" is throwing the error. Can someone explain how to properly loop through items using loop('items')? I think that is my problem. Thank you very much!

A line like get_current_record('item'); doesn't do anything by itself unless you're assigning or otherwise using it, so you don't really need that line.

I think your real problem here is the loop('items') line. The function call is correct, but you need to use it in a foreach, not a while:

foreach(loop('items') as $item) {

Of course, inside the loop you have a large number of calls to obsolete functions, but I assume you just haven't gotten that far yet.