use sqlite for collection information storage
this should be easier to extend than the multi dimensional php array used before
This commit is contained in:
parent
40a3b60bfb
commit
5ffde76d5e
3 changed files with 69 additions and 28 deletions
|
@ -1,42 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
$show_sep=true;
|
$show_sep=true;
|
||||||
|
$db = new PDO('sqlite:projects_data/projects.db') or die('database error');
|
||||||
include('header.tpl');
|
include('header.tpl');
|
||||||
?>
|
?>
|
||||||
<div id="content_padding">
|
<div id="content_padding">
|
||||||
<?php
|
|
||||||
$collectionjs = file_get_contents("projects_data/collection_data.json");
|
|
||||||
$collection = json_decode($collectionjs, true);
|
|
||||||
?>
|
|
||||||
<div class="collection_container">
|
<div class="collection_container">
|
||||||
<?php
|
<?php
|
||||||
$index = 0;
|
|
||||||
foreach($collection as $c) {
|
foreach($db->query('select id, name, cover_image from collections;') as $c) {
|
||||||
$html = '
|
$collection_id = $c['id'];
|
||||||
<div class="collection">
|
$cover_image = $c['cover_image'];
|
||||||
<div class="flexbox-col-img">
|
$collection_name = $c['name'];
|
||||||
<div class="col-img-container">
|
|
||||||
<img class="col-image" src="projects_data/img/' . $c['preview_image_url'] . '" alt="example image for ' . $c['name'] .'">
|
print("
|
||||||
<a class="col-img-desc" href="#">
|
<div class='collection'>
|
||||||
|
<div class='flexbox-col-img'>
|
||||||
|
<div class='col-img-container'>
|
||||||
|
<a class='col-img-desc' href='show_collection.php?id={$collection_id}'>
|
||||||
|
<img class='col-image' src='projects_data/img/{$cover_image}' alt='example image for {$collection_name}'>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-desc">
|
|
||||||
' . $c['collection_description'] . '
|
|
||||||
</div>
|
</div>
|
||||||
|
<h1>{$collection_name}</h1>
|
||||||
</div>
|
</div>
|
||||||
<h1>' . $c["name"] . '</h1>
|
");
|
||||||
</div>
|
|
||||||
';
|
|
||||||
}
|
}
|
||||||
print($html);
|
|
||||||
$index += 1;
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<!-- <section class="cta" style="clear: both;">
|
|
||||||
<div class="container">
|
|
||||||
<h2 class="title title-cta">Order your piece now!
|
|
||||||
</h2>
|
|
||||||
<a href="contacts.html" class="button button-dark">Order</a>
|
|
||||||
</div>
|
|
||||||
</section> -->
|
|
||||||
</div>
|
</div>
|
||||||
<?php include('footer.tpl'); ?>
|
<?php include('footer.tpl'); ?>
|
BIN
projects_data/projects.db
Normal file
BIN
projects_data/projects.db
Normal file
Binary file not shown.
51
show_collection.php
Normal file
51
show_collection.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
$show_sep=true;
|
||||||
|
$db = new PDO('sqlite:projects_data/projects.db') or die('database error');
|
||||||
|
include('header.tpl');
|
||||||
|
?>
|
||||||
|
<div id="content_padding">
|
||||||
|
<?php
|
||||||
|
// get collection parameters
|
||||||
|
$query = 'select id, name, description, cover_image from collections where id = :id';
|
||||||
|
$col_query = $db->prepare($query);
|
||||||
|
$col_query->bindParam(':id', $_REQUEST['id']);
|
||||||
|
$col_query->execute();
|
||||||
|
|
||||||
|
$collection_info = $col_query->fetch();
|
||||||
|
|
||||||
|
// get collection items
|
||||||
|
$query = 'select name, material, description, cover_image from collection_items where collection_id = :id';
|
||||||
|
$ci_query = $db->prepare($query);
|
||||||
|
$ci_query->bindParam(':id', $_REQUEST['id']);
|
||||||
|
$ci_query->execute();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
<? print($collection_info['name']); ?>
|
||||||
|
</h1>
|
||||||
|
<section class="description">
|
||||||
|
<? print($collection_info['description']); ?>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ci_container">
|
||||||
|
<?php
|
||||||
|
foreach($ci_query->fetchAll() as $ci) {
|
||||||
|
if ($ci['cover_image'] == null) {
|
||||||
|
$ci['cover_image'] = $collection_info['cover_image'];
|
||||||
|
}
|
||||||
|
$ci_img_url = 'projects_data/img/' . $ci['cover_image'];
|
||||||
|
print("
|
||||||
|
<div class='collection-item'>
|
||||||
|
<img src='{$ci_img_url}' alt='Cover picture of {$ci['name']}' />
|
||||||
|
<h1>{$ci['name']}</h1>
|
||||||
|
</div>
|
||||||
|
");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?
|
||||||
|
include('footer.tpl');
|
||||||
|
$db = null;
|
||||||
|
?>
|
Loading…
Reference in a new issue