Skip to content

Instantly share code, notes, and snippets.

@sixteenstudio
Created September 18, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixteenstudio/22e7027706defd8df35b to your computer and use it in GitHub Desktop.
Save sixteenstudio/22e7027706defd8df35b to your computer and use it in GitHub Desktop.
Generation script
<!doctype html>
<html>
<head>
<meta name="dompdf.view" content="XYZ,0,10000,1" />
</head>
<body>
<style>
/*
=== Catalogue Styles ==
*/
html {
margin: 0;
}
body {
padding: 0;
margin: 0;
color: #333333;
font-family: 'Helvetica';
}
.top-border {
display: block;
border-top: 13px solid #cc682d;
margin: 0;
width: 100%;
background-color: #333;
height: 4px;
}
/*
=== Master Catalogue Table ===
This is inherited throughout the catalogue as it includes the correct padding
for document borders
*/
.catalogue-table {
width: 92%;
/* dompdf setting */
padding-left: 8%;
/* html setting */
margin-left: 4%;
/* end cross */
border-collapse: collapse;
}
.catalogue-table tr {
padding: 0;
}
.catalogue-table td {
padding: 0;
}
.image-cell img {
vertical-align: middle;
}
/*
=== Main Catalogue Title Table ===
*/
.catalogue-table.catalogue-title-table {
margin-top: 7px;
}
.catalogue-table.catalogue-title-table .image-cell {
text-align: left;
}
.catalogue-table.catalogue-title-table .title-cell {
text-align: right;
font-size: 34px;
color: #333;
font-weight: bold;
}
.catalogue-table.catalogue-title-table {
}
/*
=== Category Headings ===
*/
.catalogue-table.category-heading-table {
margin-top: 22px;
padding-top: 35px;
}
.catalogue-table.category-heading-table .image-cell {
width: 5%;
text-align: right;
}
.catalogue-table.category-heading-table .name-cell {
width: 95%;
background-color: #333333;
vertical-align: middle;
color: #fff;
font-size: 26px;
font-weight: bold;
padding-left: 28px;
}
.catalogue-table.subcategory-table {
margin-top: 26px;
}
.catalogue-table.subcategory-table .title-cell {
font-weight: bold;
font-size: 22px;
}
.catalogue-table.subcategory-table .description-cell {
font-weight: normal;
font-size: 17px;
}
.catalogue-table.subcategory-table .description-cell strong {
font-weight: normal;
}
.catalogue-table.subcategory-table .description-cell p {
margin: 0;
padding: 0;
}
.catalogue-table.sub-subcategory-table {
margin-top: 20px;
}
.catalogue-table.sub-subcategory-table td {
padding-left: 30px;
}
.catalogue-table.sub-subcategory-table .title-cell {
font-weight: bold;
font-size: 19px;
}
.catalogue-table.sub-subcategory-table .description-cell {
font-weight: normal;
font-size: 14px;
}
.catalogue-table.sub-subcategory-table .description-cell strong {
font-weight: normal;
}
.catalogue-table.sub-subcategory-table .description-cell p {
margin: 0;
padding: 0;
}
.catalogue-table.sub-sub-subcategory-table {
margin-top: 12px;
}
.catalogue-table.sub-sub-subcategory-table td {
padding-left: 60px;
}
.catalogue-table.sub-sub-subcategory-table .title-cell {
font-weight: bold;
font-size: 19px;
}
.catalogue-table.sub-sub-subcategory-table .description-cell {
font-weight: normal;
font-size: 14px;
}
.catalogue-table.sub-sub-subcategory-table .description-cell strong {
font-weight: normal;
}
.catalogue-table.sub-sub-subcategory-table .description-cell p {
margin: 0;
padding: 0;
}
/*
=== Product tables ===
*/
.catalogue-table.product-table {
margin-top: 10px;
}
.catalogue-table.product-table .name-cell {
font-weight: bold;
font-size: 18px;
text-align: left;
}
.catalogue-table.product-table .product {
background-color: #fbfbfb;
border: 1px solid #b1b1b1;
}
.catalogue-table.product-table.level-1 td {
padding-left: 0;
}
.catalogue-table.product-table.level-2 td {
padding-left: 28px;
}
.catalogue-table.product-table.level-3 td {
padding-left: 45px;
}
.catalogue-table.product-table.level-4 td {
padding-left: 60px;
}
/*
=== Product Option Tables ===
*/
.catalogue-table.option-table {
width: 100%;
padding: 0;
margin: 0;
}
.catalogue-table.option-table th {
background-color: #333333;
color: #fff;
padding-top: 4px;
padding-bottom: 4px;
font-size: 17px;
font-weight: normal;
text-align: left;
}
.catalogue-table.option-table td, .catalogue-table.option-table th {
font-size: 15px;
padding-left: 5px !important;
}
.catalogue-table.option-table td {
padding-top: 3px !important;
padding-bottom: 3px !important;
border-bottom: 1px solid #787878;
}
.catalogue-table.option-table tr:last-child td {
border-bottom: 0;
}
/*
=== Print Divisors ===
Not currently used, should be used to gel titles to their tables
*/
.print-division {
page-break-inside:avoid;
}
</style>
<div class="top-border"></div>
<table class="catalogue-table catalogue-title-table">
<tr>
<td class="image-cell"><img src="assets/img/logo.png" /></td>
<td class="title-cell">Product Catalogue</td>
</tr>
</table>
<!-- Echo out each category -->
<? foreach($categories as $category): ?>
<table class="catalogue-table category-heading-table">
<tr>
<td class="image-cell"><img src="assets/images/size/56x84/<? echo $category['image'] ?>" /></td>
<td class="name-cell"><? echo $category['category_name'] ?></td>
</tr>
</table>
<!-- Echo out each product -->
<? if($category['products']): ?>
<? foreach($category['products'] as $product): ?>
<table class="catalogue-table product-table level-1">
<tr>
<td class="name-cell"><? echo $product['product_name'] ?></td>
</tr>
<tr>
<td class="product-cell">
<div class="product">
<table class="catalogue-table option-table" class="grid_3 alpha">
<thead>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<th style="width: <? echo $product['optionColumnWidth'] ?>%;"><? echo $optionField ?></th>
<? endforeach; ?>
</tr>
</thead>
<tbody>
<? foreach($product['options'] as $option): ?>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<td><? echo $option[$optionFieldKey] ?></td>
<? endforeach; ?>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>
</td>
</tr>
</table>
<? endforeach; ?>
<? endif; ?>
<? if($category['subcategories']): ?>
<!-- Echo out each subcategory inside this category -->
<? foreach($category['subcategories'] as $subcategory): ?>
<table class="catalogue-table subcategory-table">
<tr>
<td class="title-cell"><? echo $subcategory['category_name'] ?></td>
</tr>
</table>
<!-- Echo out each product -->
<? if($subcategory['products']): ?>
<? foreach($subcategory['products'] as $product): ?>
<table class="catalogue-table product-table level-2">
<tr>
<td class="name-cell"><? echo $product['product_name'] ?></td>
</tr>
<tr>
<td class="product-cell">
<div class="product">
<table class="catalogue-table option-table" class="grid_3 alpha">
<thead>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<th style="width: <? echo $product['optionColumnWidth'] ?>%;"><? echo $optionField ?></th>
<? endforeach; ?>
</tr>
</thead>
<tbody>
<? foreach($product['options'] as $option): ?>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<td><? echo $option[$optionFieldKey] ?></td>
<? endforeach; ?>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>
</td>
</tr>
</table>
<? endforeach; ?>
<? endif; ?>
<!-- Echo out each subcategory inside this subcategory -->
<? if($subcategory['subcategories']): ?>
<? foreach($subcategory['subcategories'] as $subSubcategory): ?>
<table class="catalogue-table sub-subcategory-table">
<tr>
<td class="title-cell"><? echo $subSubcategory['category_name'] ?></td>
</tr>
</table>
<!-- Echo out each product -->
<? if($subSubcategory['products']): ?>
<? foreach($subSubcategory['products'] as $product): ?>
<table class="catalogue-table product-table level-3">
<tr>
<td class="name-cell"><? echo $product['product_name'] ?></td>
</tr>
<tr>
<td class="product-cell">
<div class="product">
<table class="catalogue-table option-table" class="grid_3 alpha">
<thead>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<th style="width: <? echo $product['optionColumnWidth'] ?>%;"><? echo $optionField ?></th>
<? endforeach; ?>
</tr>
</thead>
<tbody>
<? foreach($product['options'] as $option): ?>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<td><? echo $option[$optionFieldKey] ?></td>
<? endforeach; ?>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>
</td>
</tr>
</table>
<? endforeach; ?>
<? endif; ?>
<!-- Echo out each subcategory inside this subcategory -->
<? if($subSubcategory['subcategories']): ?>
<? foreach($subSubcategory['subcategories'] as $subSubSubcategory): ?>
<table class="catalogue-table sub-sub-subcategory-table">
<tr>
<td class="title-cell"><? echo $subSubSubcategory['category_name'] ?></td>
</tr>
</table>
<!-- Echo out each product -->
<? if($subSubSubcategory['products']): ?>
<? foreach($subSubSubcategory['products'] as $product): ?>
<table class="catalogue-table product-table level-4">
<tr>
<td class="name-cell"><? echo $product['product_name'] ?></td>
</tr>
<tr>
<td class="product-cell">
<div class="product">
<table class="catalogue-table option-table" class="grid_3 alpha">
<thead>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<th style="width: <? echo $product['optionColumnWidth'] ?>%;"><? echo $optionField ?></th>
<? endforeach; ?>
</tr>
</thead>
<tbody>
<? foreach($product['options'] as $option): ?>
<tr>
<? foreach($product['optionFields'] as $optionFieldKey => $optionField): ?>
<td><? echo $option[$optionFieldKey] ?></td>
<? endforeach; ?>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>
</td>
</tr>
</table>
<? endforeach; ?>
<? endif; ?>
<? endforeach; ?>
<? endif; ?>
<? endforeach; ?>
<? endif; ?>
<? endforeach; ?>
<? endif; ?>
<? endforeach; ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment