The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

emdeboas (7) [Avatar] Offline
Thanks for taking the effort to write a much needed book!

To be able follow the rest of the book, it would be nice to have a working version of the
QuickGallery example. I ran into a few problems trying to get it running. Maybe I can save others some time, and maybe a few things can be improved in the book.

1. My first problem was the remark in 2.2.1:
...added a symbolic link to my home directory called 'sites', pointing to /var/www/dave.
I have no clue what this means, therefore after seeing a lot of empty image boxes, I came up with:

$basedir = '/xampp/htdocs/quickgallery';
$img_pre_path = '/quickgallery';

Where /xampp/htdocs/ is my server root and quickgallery the subdirectory of the server root where the images are stored.

2. The second problem is the names of the files. It would be nice if the headings of the listings would say the name that the file is supposed to have, so for example:
Listing 2.1, Business logic for QuickGallery

3. Then, the annotation marks which are in the text result in invalid, not working code, because they are not seen as comments. I assume that they will not be in the source code of the final book, but for now it is annoying.

4. In the CSS file, font-face should be font-family

5. In images.php, there is one more end-a tag than there are start-a tags

6. I think there is a bug in the breadcrumbs: if you click on the name of an image in a fully expanded breadcrumb, you get a wrong path to the image.

7. The design of QuickGallery is maybe a bit too simple. I can see many who would like to expand the example to include images stored in databases, and where the set of thumbnails to display is not all images in a directory but search results in a query on keywords or tags. This is forgivable, but I have a real concern with images.php.

8. The code for images.php is not something I would consider good programming style. It is very hard to see what is going on and how this piece of code could be made reusable in other projects. Spending about an hour on rewriting this script I came up with something that is not good (because wanted to stay close to the original), but at least I understand how it works:

<?php require(''); ?>
<link rel='stylesheet' type="text/css" href="images.css">

<br /> $self = $_SERVER['PHP_SELF'];
echoTitleArea($crumbs, $self); 
echoSubarea($closeup, $subdirs, $imgs, $img_pre_path, $path, $self );

<br /> function echoTitleArea($crumbs, $self) {
    echo "hallo!";
    echo "<div id='title' class='box'>";
    foreach ($crumbs as $i => $value){ 
        $path = $value['path'];
        $name = $value['name'];
        echo <<<_CRUMB
            <a >$name</a>
echo '</div>';

function echoSubarea($closeup, $subdirs, $imgs,$img_pre_path, $path, $self ) {
    if ($closeup){ 
        displayCloseup($img_pre_path, $path);
    }else {
        if (count($subdirs)>0){ 
        if (count($imgs)>0){  
            displayThumbnails($imgs, $path, $img_pre_path ); 

function displayCloseup($img_pre_path, $path) {
    echo <<<_CLOSEUP
    <div id='closeup' class='box'>
    <img >

function displaySubdirs($subdirs,$path) {
        echo "<div id='folders' class='box'>";
        foreach ($subdirs as $i => $value){  
            $subpath = implode('/',array($path,$value));
            echo <<<_SUBDIRS
                <a >$value</a>
    echo "</div>

function displayThumbnails($imgs, $path, $img_pre_path ){
        echo "<div id='images' class='box'>";
        foreach ($imgs as $i => $value){
            echo <<<_IMG
            <div class='img_tile'> 
                <a >
                <img  />
    echo "</div>

Cheers! Ghica
MikeTurbo (1) [Avatar] Offline
Re: The QuickGallery example in chapter 2
Thanks for this article!
It helped!