It's a image gallery, that work with a simple admin-template, with current standard fields:
-title
-summary //little explanation of current gallery
-headline
-images
So here is the template code
--------------------------------------------------
<?php
/**
* Image gallery template
* named bildgalleri.php
* Created by Max Allan Niklasson a.k.a. rödgladan
* Share and use!
*/
include("./head.inc");
echo '<style>';
echo '.image-gallery .image-controls{border-bottom:1px solid #CCC;}';
echo '.image-gallery-desc {padding-left:10px;font-style:italic;}';
echo '.image-gallery .image-controls a{color:#FF9494 !important;}';
echo '.image-gallery .image-controls table{width:100%;padding:0px !important; margin:0px !important; border-collapse:collapse;}';
echo '.image-gallery .image-controls table tr td{width:29.99%;}';
echo '.image-gallery .image-controls table tr td.image-prev{text-align:left;}';
echo '.image-gallery .image-controls table tr td.image-thumbs{text-align:center;}';
echo '.image-gallery .image-controls table tr td.image-next {text-align:right;}';
echo '.image-gallery .image-viewer {padding-top:30px; text-align:center;}';
echo '.image-gallery .image-description {font-style:italic;}';
echo '.image-table {border-collapse:separate;border-spacing:10px;}';
echo '.image-table tr td{padding:10px 10px 4px 10px!important;border:1px solid #DCDCDC;text-align:center;vertical-align:middle;}';
echo '.image-table tr td a:hover{background-color:transparent !important;}';
echo '.image-table tr td p.table-desc{margin:0px !important;color:#CCC;}';
echo '</style>';
if(!$_GET['img']){
echo "<p class='image-gallery-desc'>{$page->summary}</p>";
//Get subgalleries
$numberPages = count($page->children);
if($numberPages) {
echo '<h3>Album under <i>'.$page->title.'</i></h3>';
echo '<table class="image-table"><tr>';
for($i = 0;$i < $numberPages;$i++){
//To find sub images use this
$subPage = $page->children('template=bildgalleri')->eq($i);
//To just get the informationen of the relative sub gallery
$nextPage = $page->children('template=bildgalleri')->eq($i);
//The thumb to this gallery
$cover = $subPage->images->first();
if(!$cover){ //If no sub images is find, digg!
$coverIsDef = false;
//Search of childed images, and take the first found image
while($coverIsDef===false){
$whileSubPage = $subPage->children('template=bildgalleri')->first();
$cover = $whileSubPage->images->first();
if($cover)
$coverIsDef = true;
else
$subPage = $whileSubPage;
}
}
if($cover){ //When images is found, make thumb of it
$coverThumb = $cover->size(140,140);
}
//Write out the nice image whit link
echo "<td><a href='{$nextPage->url}'>
<img src='{$coverThumb->url}' alt='{$nextPage->summary}' width='{$coverThumb->width}' height='{$coverThumb->height}' /><p class='table-desc'>{$nextPage->title}</p>
</a></td>";
}
//Row break
if($i > 0 && $i % 4 == 0){echo'</tr><tr>';}
echo '</tr></table>';
}
//Get images to this gallery
$numberImages = count($page->images);
if($numberImages){
echo "<h3>Foton under <i>".$page->title."</i></h3>";
echo '<table class="image-table"><tr>';
for($i = 0;$i < $numberImages;$i++){
$image = $page->images->eq($i);
$thumb = $image->size(140,140);
echo "<td><a href='?img={$image->name}'>
<img src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' />
</a></td>";
//Row break
if($i > 0 && $i % 4 == 0){echo'</tr><tr>';}
}
echo '</tr></table>';
}
}
//Image view of one image!
else{
$images = $page->images;
$image = $images->get($_GET[img]);
$nextImage = $image->getNext();
$prevImage = $image->getPrev();
$sizedImage = $image->size(700);
echo "<div class='image-gallery'>";
echo "<div class='image-controls'>";
echo "<table><tr>";
echo "<td class='image-prev'>".($prevImage != false ? "<a href='?img={$prevImage->name}'>":"")."Föregående".($prevImage != false ? "</a>":"")."</td>";
echo "<td class='image-thumbs'><a href='./'>Miniatyrer</a></td>";
echo "<td class='image-next'>".($nextImage != false ? "<a href='?img={$nextImage->name}'>":"")."Nästa".($nextImage != false ? "</a>":"")."</td>";
echo "</tr></table>";
echo "</div>";
echo "<div class='image-viewer'>";
echo "<img src='{$sizedImage->url}' />";
echo "<div class='image-description'>{$image->description}</div>";
echo "</div>";
echo "</div>";
}
include("./foot.inc");
-----------------------------------------------------------I also changed in the head.inc so the sub menu will not be printed if the template is "bildgalleri" (the name of my template).
if($page->template != 'bildgalleri')
Is there any way to clean it up, or ideas?












