Category: Web Development


When presenting information to a user on a web page one or many photos makes a dramatic difference (in fact I always like to include one on a blog post – like this one).  The challenge I had in this iteration of my website was how to best present a series of photos related to some text on my “History with Trains” page.  I could have just embedded the images right into the text – but I wanted something that looked better.

Years ago when I building web pages there wouldn’t be many choices for this – today we have the opposite problem  - there are so many options.  On other web pages I have used a “lightbox” style approach – where the image expands in a smooth fashion from the thumbnail to the full-size image (for an example click on one of the room pictures toward the bottom of this page).  I could have done that – but I wanted to group the pictures together with a nice visual effect.

As part of learning Dreamweaver CS5 I’ve been playing around with the “Widget Browser”.  I found a “lightbox” widget and played around with this.  It gave me the interesting format – the filmstrip like effect on the right-side of the screen I’ve shown here.  It has nice effects like hovering, lightbox style expansion, and it even rotates through the pictures at their full size (I probably should have re-sized these pictures to fit the screen better – usually an 800 max width works best).  There are other “widgets” related to images – take a look one on this page – that again creates a visually pleasing effect.

The reality is you can find so many different options – such as on Dynamic Drive.  The best thing would be to search around and find one that works best for you – both in appearance and how easy it is to create/maintain.  For lots of images photo gallery software would be better – such as Gallery 3 – like I have implemented here.   This pretty much completes my short series of blog posts on building this new site.  Here are the previous posts:

 

In my last post I discussed how I updated a Gallery 3 theme to have my custom background.  In this post I will discuss how I added a custom header and footer to my theme (to match the rest of my site).

Adding a customer header

Part of the uniqueness of most sites is the header- the logo, phrases, and often navigation.  So again the trick was to find where to put my custom header. I started with the “page.html.php” file:

<body <?= $theme->body_attributes() ?>>

<?= $theme->page_top() ?>

<div id="doc4" class="yui-t5 g-view">

<?= $theme->site_status() ?>

<div id="g-header" class="ui-helper-clearfix">

<div id="g-banner">

<? if ($header_text = module::get_var("gallery", "header_text")): ?>

<?= $header_text ?>

<? else: ?>

<a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">

<img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" />

In looking at this file I know the custom header must be within the <div id=”doc4″> I identified before.  I decided I didn’t want to replace the existing header of the site – but put mine on top of the existing one (minus the logo).  The biggest challenge was again the image – how to find the right syntax for the image.  So I looked at how they originally set up the logo:

<img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" />

The key to the image was how it was formatted – with a “file” reference instead of url.  The logo is not actually in the theme folder – but in a different folder off the root of the gallery 3 installation.  This is actually what gallery 3 produces from the above:

<img width="107" height="48" alt="Gallery logo: Your photos on your web site" src="/photos3/lib/images/logo.png" />

Therefore, given that my image is in the “/images” folder I formatted my image as follows:

<img width="81" height="100" align="left" alt="<?= t("Andrew Loves Trains")->for_html_attr() ?>" src="<?= url::file("../images/logo.jpg") ?>" />

The next part was simple – in that I copied the source code of my header from my normal template into the theme – inside the “<div id=”g-header” class=”ui-helper-clearfix”>” .  In order to format it the same I had to add my css in the “source.css” file – I basically added my own section:

/** Andrew's Unique Styles */
#andrew_header {
width: 100%;
height: 105px;
padding-top: 5px;
}

The correct coding for any links in the header is like follows: “<a href=”/index.html”>Home</a>”.  The remaining task was to add my custom footer.  Here is what the bottom of the “page-html.php” looks like:

<? if (module::get_var("gallery", "show_credits")): ?>
<ul id="g-credits" class="g-inline">
<?= $theme->credits() ?>
</ul>
<? endif ?>
</div>
</div>
<?= $theme->page_bottom() ?>
</body>
</html>

After some experimentation I determined that the best place to add the footer was after the “<?= $theme->page_bottom() ?>”.   Again the key is update the “screen.css” with any custom css – in  my case a custom image background. Here is what the updated footer looks like:

</div>
<div id="footer">
<div id="footer_text">
<p><a href="/index.html">Home</a> | <a href="/trains_history.html">My History with Trains</a> | <a href="/photos3">Photos</a> | <a href="/my_creations.html">My Creations</a>| <a href="/my_videos.html">My Videos</a> | <a href="/contact_me.html">Contact Me</a></p>
<p>Copyright @2010 - courtesy of <a href="http://www.andrewhelpme.com" target="_blank">Andrew, Help Me!</a> </p>
</div>
</div></div>
<?= $theme->page_bottom() ?>

As I said in my previous post Gallery 3 was one of the primary drivers for building out this website again. I had previously tested the Gallery 3 installation a few times to be sure it worked – that I can upload and organize photos, view a slide show, etc.  It was time though to create my own “theme” – in order to match the rest of my site.   As is common my “template” (which I actually finished developing as I worked on this customization) had a consistent top and bottom – which I find easier to fit with applications.

As this was basically a new application I looked on the Gallery website to find out how to modify a template.  Unfortunately the instructions on the website left some gaps – so I did a lot of hacking.  The website did provide the basic information of how a theme is organized into folders:

  • css – simply css files
  • images – images used by the template
  • js – special javascript for the template
  • views – php files for the components of the gallery

The “js” folder was one I didn’t mess with but in the “css” folder I found a key file: “screen.css”.  This is the main css file for the theme.  In the “views” folder I found the “page.html.php” file – which also defines the basic layout of a page.  I found these 2 files to be the key files to edit when modifying a theme (I agree with their recommendation – copy the default “wind” theme’s folder and modify that).

Changing the background to match site

The first challenge was to change the background of the photo gallery to match the background of my site design – the image behind everything.  So I focused my efforts on the “screen.css” file – looking for the body tag. I found the body tag in the css file:

/** *******************************************************************
*  1) Font sizes, base HTML elements
**********************************************************************/
body, html {
background-color: #ccc;
font-family: 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
p {
margin-bottom: 1em;
}

The default theme had a background color set -which defined the area outside the main container of the photo album.  I wanted to change this to be the same image file as the one I was using on the rest of my site:

body {
	background-color: #C3026F;
	font-family: 'Coming Soon', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
	font-size: 13px;
	background-image: url(images/P8133933.JPG);
	font-weight: 100;
}

The challenge was how to do I specify the location of that file – given it’s in a different set of folders.  I tried to point to the site’s images folder- but basically I was unsuccessful. The reason is that this is dynamic code – therefore what I type into this css may not be what comes out. Therefore I went to plan B – and copied that image to the “images” folder of my theme.  Here is the difference between what I typed in and what came out.

Original CSS

body, html {
  background-image: url('../images/P8133933.JPG');
  font-family: 'Coming Soon', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

Generated CSS

body, html {
  background-image: url('http://www.andrewluvtrains.com/photos3/themes/andrew_wind/css/../images/P8133933.JPG');
  font-family: 'Coming Soon', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

Changing the background of the container

What I wanted next to do was make it to where I could see that in the container of the photos – the space between the thumbnails, etc.  The problem was I wasn’t sure what to change – which css property was it?  To figure that out I needed to look at the other main file involved – page.html.php.  I opened up this file and began searching for the <div> that was the “container”.  Here’s what I found:

<body <?= $theme->body_attributes() ?>>
<?= $theme->page_top() ?>
<div id="doc4" class="yui-t5 g-view">
<?= $theme->site_status() ?>
<div id="g-header" class="ui-helper-clearfix">
<div id="g-banner">
<? if ($header_text = module::get_var("gallery", "header_text")): ?>
<?= $header_text ?>
<? else: ?>
<a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
<img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" />
</a>
<? endif ?>
<?= $theme->user_menu() ?>
<?= $theme->header_top() ?>

I realized that the <div id=”doc4″ class=”yui-t5 g-view”> was the key – as this was the first div within the <body>.  Therefore I had to figure out how the id of “doc4″  the class “yui-t5 g-view” was formatted.  So I searched for these ids/classes through the various css files in gallery3.   I had some trouble finding these files – but I had a clue that Gallery3 used the YUI framework – including the YUI grids.  So I looked up the YUI Grids page to see what I could find and found a cheat sheet that explained the YUI grid syntax (the YUI framework has very good documentation).  It found that the id of “doc4″ meant a 974 byte width and that a class of “yui-t5″ meant a sidebar of 240.

Therefore I was down to “g-view” – which i found in the screen.css file:

/* View container ~~~~~~~~~~~~~~~~~~~~~~~~ */
.g-view {
background-color: #fff;
border: 1px solid #ccc;
border-bottom: none;
}

So I needed to update this to allow for a semi-transparent background. Therefore I copied over my semi-transparent white png file to the “images” folder of my theme and updated the css as follows:

/* View container ~~~~~~~~~~~~~~~~~~~~~~~~ */
.g-view {
/*background-color: #fff; */
background-image: url(../images/white_transparent30.png);
border: 1px solid #ccc;
border-bottom: none;
}

Fixing the sidebar

So I had my background image now showing through – but I noticed that the text in the sidebar was now hard to read.  So I needed to figure out where that css was – so I could adjust it.  I created a different background image – one that wasn’t as transparent and looked in screen.css:

#g-sidebar {
padding: 0 20px;
width: 220px;
}

I replaced it with this:

#g-sidebar {
padding: 0 20px;
width: 220px;
background-image: url(../images/white_transparent30a.png);
}

In my next post I’ll talk about how I added my custom header and footer to the theme.

One of my websites – andrewluvtrains.com – has been in a state of disrepair for a few months now. I’ve been so busy with other things that I could never seem to get back to it.  This was actually the first modern website I’ve had (my previous ones we’re rough and incomplete). I broke some of the content that was originally on my train website into multiple websites – with the goal of keeping each website focused on one subject). That said, I still wanted to keep this website up and running – and it wasn’t.

One of the primary characteristics of my trains website was photos – lots of photos. For many years I’ve been using Gallery2 on my websites and on many of my clients – as it was an excellent photo gallery – easy to upload and very usable.  The Gallery Community decided in 2010 that Gallery 2 was at it’s end of life – and that a completely new build of the Gallery – Gallery 3 – needed to be produced.  Therefore my trains website became a testing site for this new gallery – including doing some release candidate testing (I have to give credit to the community for working the issues I found in a rapid manner).

My methods are the same with every site – create the “template” that the whole site is based on (header, footer, background, etc.).  I’ve been trying to be a little more artistic in building my websites – as some I’ve done in the past are pretty utilitarian.  The trains site lent itself well to this – as the photos make it a lot easier to create something pleasing to the eye.  Therefore I came up with a template using these characteristics:

  • I wanted to keep it clean – where the “header” of the site was pretty minimal. Therefore I added a simple train image (my logo) and the name of the website “Andrew Loves Trains” (text)
  • I also kept the menu very simple – simply words as hyperlinks – no images, drop-downs, etc.
  • One of the common approaches I’ve used lately is to have a fixed layout – with the body having a very large image behind it. In this case I had a nice train photo to serve as the very large image.
  • I decided to keep this image as central to the site – so the background of the content and the header is simply a semi-transparent white image.
  • The footer continued this pattern – except with a series of semi-transparent images to make the footer look different.

The other thing I wanted to do with this website was try a different font – instead of the standard set of web fonts.  Therefore I went to the Google Font Directory to look for a special font.  There are a growing number of new fonts to choose from (more than when I first looked a few months ago).  I decided on “Coming Soon”  as my website font – to give it a distinctive look.  What’s nice about the Google fonts is all I have to do is import their css definition and add it to my css definitions (in my case the body).

Therefore I created the template that’s visible in the website – using a combination of css (backround images, fonts, etc.) and a template in Dreamweaver.  Then I created each page from this template – for consistency of look and feel, as well as navigation.  I’ve finally moved away from tables – so it’s all in DIVs with CSS formatting.

Get Adobe Flash player
I'm a proud member of the WordPress Users Association, Become a member today