0

MVCアプリケーションでの作業と画像配列の取得:

コントローラ

<?php
// model
$this->load->model('catalog/manufacturer');
// data array
$this->data['manufacturers'] = array();
// database data
$results = $this->model_catalog_manufacturer->getManufacturers();
// populating array
foreach ($results as $result)
  {
  $this->data['manufacturers'][] = array(
    // HTTP_IMAGE is where images are stored
    'thumb' => HTTP_IMAGE . $result['image'],
    'href'  => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $result['manufacturer_id'])
  );
  }
// view
$this->render();
?>

画像はさまざまな比例サイズ(正方形、垂直、水平)になっています。

狭い画像と広い画像を交互に(レンダリングする前に)配列を並べ替えるにはどうすればよいですか?(クライアントの請願は想像よりも奇妙です)。

4

1 に答える 1

1

このようなことをするのはどうですか?

1)すべての画像を取得し、アスペクト比でリストを並べ替えます

2)リストを前半と後半に切り刻む

3)いくつかのアルゴリズムに従って、前半と後半の画像を交互に使用します(左から取得、右から取得、または各半分にランダムであるため、すでに9つの可能性があります)

于 2013-01-22T03:10:58.547 に答える