-
-
Save nishad/dcd7b5e672c10c17dfa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /*?>* function csv_to_array | |
* @link http://gist.github.com/385876 | |
* @author Jay Williams <http://myd3.com/> | |
* @copyright Copyright (c) 2010, Jay Williams<?php */?> | |
<?php | |
$imagelist= $page->imagelist(); | |
if ($imagelist != ''){ | |
function csv_to_array($filename='', $delimiter=',') { | |
if (!file_exists($filename)) | |
return 'not exist'; | |
if (!is_readable($filename)) | |
return 'not readable'; | |
$header = NULL; | |
$data = array(); | |
if (($handle = fopen($filename, 'r')) !== FALSE) { | |
while (($row = fgetcsv($handle, 200, $delimiter)) !== FALSE) { | |
if (!$header) | |
$header = $row; | |
else | |
$data[] = array_combine($header, $row); | |
} | |
fclose($handle); | |
} | |
return $data; | |
} | |
function createModels($data) | |
{ | |
$newRow = array(); | |
$newData = array(); | |
if (is_array($data)){ | |
foreach($data as $rowIndex => $row){ | |
if(is_array($row)){ | |
$newRowIndex = $row['Stock book code']; | |
} | |
$newData[$newRowIndex] = array_merge($newRow, $row); | |
} | |
} | |
return $newData; | |
} | |
$imageInfoArray = csv_to_array('assets/artistswork/imagemeta.csv'); | |
$imageMetaIndexed = createModels($imageInfoArray); ?> | |
<div id="gallery" class="row-fluid"> | |
<ul class="gallery"> | |
<?php | |
$galItemid = 1; | |
$imagelistitem= explode(", ", $imagelist); | |
foreach ($imagelistitem as $image): ?> | |
<li> | |
<div id="galItem<?php echo $galItemid?>" class="galleryItem row-fluid"> | |
<div class="imageBox span8"><img src="<?php echo url('assets/artistswork/450/').$image.'.jpg' ?>" alt="<?php echo $imageMetaIndexed[$image]['Work Title']?>"></div> | |
<div class="imageMetaBox span4"> | |
<span class="workTitle"><?php echo $imageMetaIndexed[$image]['Work Title']?></span> | |
<span class="workDate"><?php echo $imageMetaIndexed[$image]['Date']?></span> | |
<span class="workMaterial"> | |
<?php if (($imageMetaIndexed[$image]['materials']) != '0') {echo ($imageMetaIndexed[$image]['materials']);} | |
?> | |
</span> | |
<span class="workDimensions"> | |
<?php if (($imageMetaIndexed[$image]['width']) != '0') { echo ($imageMetaIndexed[$image]['width'].' x '.$imageMetaIndexed[$image]['height']); }?> | |
</span> | |
<span class="workPrice"><?php if (($imageMetaIndexed[$image]['Ownership']) != '0') {echo $imageMetaIndexed[$image]['Ownership'];}?></span> | |
</div> | |
</div> | |
</li> | |
<?php | |
$galItemid += 1; | |
endforeach ; ?> | |
</ul> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment