Author: mikef
Version: 1.2 (prelim)
This document last updated 18th September 2006
[
Prerequisites:[/u]]
- Minimum Etomite version: 0.6.1
- Etogal: A copy of Etogal version 1.0 or later is also required, as this snippet uses the etogal database and image store, and has no management capabilities of its own.
[
Features:[/u]]
- display EtoGal images or galleries on different page from the gallery id
- select specific images to display by id or subject
- select specific galleries to display by gallery page id
- limit the number of images to display
- flexible image sorting (including random)
- (relatively) easy generation of your own display styles (needs HTML knowledge rather than PHP)
- add section breaks based on number of images or gallery an image belongs to
- a single random image (out of three relevant images) in a news article
- three random images to act as a separator half way down a page
- thumbnails of all the images in a gallery, with their descriptions, with a link to the gallery page
- a random choice of four images from a gallery with the gallery's long title and description, all linking to a custom gallery page
Another example of its use can be found at Efikim Galleries, where a separate call of the snippet is made for each of the galleries. (These use a style similar to the second example near the bottom of this post, though the URL generation for the image links is a little more complex.)
[
Installation instructions:[/u]]
- Download the latest Etogalthumb.php file from the Etogal download area and add it to your installation as a snippet (copy the contents into new snippet).
- That's it!
[
Options you can pass to the EtoGalThumb Snippet:[/u]]
- only,not - page id where thumbnails should/should not be shown (default is show on any page - these are useful for pages that are shown elsewhere in condensed form (eg news items))
- link - page id parameter to be used in links (%%link%% parameter)
- gal - gallery from which images are to be shown (optional, can be a comma separated list)
- img - id of image to be shown (optional, can be a comma separated list)
- subject - (new) 'subject' of images to be shown (text match in image title or description)
- if none of gal, img or subject are defined, all images are used (subject to and exclude specificatio)
- only one of gal, img or subject should be specified, if two or three are used, the priority order is gal, img, sunbject - exclude - id list of images to exclude when selecting by gallery
- addback - increase total images count by this value
- count - number of images to use (defaults to 1, if you want all, specify 9999)
- order_by - maye be set to 'id','gal_id','title','filename','descr','date' and orders by that entry in the EtoGal table
- if no order is specified, then the order in which results are returned is random (the list returned from the database is deliberately shuffled)
- 'random' is NOT a valid value
- ordering using two valid fields separated by a comma should work, but is untested - order_direction - "ASC" (default) or "DESC"
- style - style to be used (required; behaviour if not provided is undefined)
- valid values depend on the styles defined in the snippet, and may be either numeric or text - fullsize - set this to 1 to use fullsize images instead of thumbnails (other values undefined)
- default is not set (means use thumbnails) - resize - desired pixel count on longest side - adjusts the width and height returned in the %%size%% string to give the desired size
- breakat - insert a section break after each 'breakat' images
- gallerybreak - inserts a section break whenever the gallery that the next image belongs to changes
HTML presentation blocks are created at the head of the code in 'style' blocks, with each style having three blocks - header, image and tail.
The header and tail style blocks use only a limited number of parameters, related to the page id passed as the link parameter. As implied by the names, the header block is output before the block of images, and the tail block is output after the images.
The image style block has access to all the parameters used in the head and tail styles, plus additional parameters related to the current image and the gallery it is in. It is output once for each image selected.
All of these style blocks are optional.
[
Replaceable strings for use in styles:[/u]]
strings available for the 'head' and 'tail' style strings
as above plus
strings available for the 'head' and 'tail' style strings
- %%alias%% - the alias for the page passed as the link page
- %%link%% - the link page id
- %%ptitle%% - the longtitle for the link page
- %%pdesc%% - the description for the link page
- %%total%% - the total number of images selected
- %%baseurl%% - (the url of the page specified in the link parameter (FURL if enabled)
- %%sep%% - the separator string for the first parameter to add to a page URL (varies depending on the baseurl format)
as above plus
- %%id%% - the image id
- %%size%% - the pixel dimensions for the image file (width and height) as a quoted string as required in an <img> element
- %%file%% - filename for the image (full path) - this will be for the thumbnail image unless fullsize is specified, when it will be for the full sized image
- %%fsfile%% - (new) filename for the full size image (full path) - tjis is useful where you want to use the thumbnail for display, but need the path to the fullsize image for other purposes (eg when using thickbox)
- %%title%% - title for the image (from the etogal database table)
- %%desc%% - description for the image (from the etogal database table)
- %%sdesc%% - truncated description (or title if no description present)
- %%gal%% - the gallery in which the image exists
- %%gtitle%% - the longtitle for the gallery page
- %%gdesc%% - the description for the gallery page
- %%galias%% - the alias for the gallery page
- %%gurl%% - the URL for the gallery page
To use, design the HTML you need for your display, and then put the above %%xxxx%% string in the HTML code where you want the associated data to appear, as in the examples below. Then put the resulting HTML into the styles at the head of the snippet.
[
Example styles[/u]]
First, a very simple display that just displays the selected image(s) with no links. In this example the header and tail blocks aren't used.
and a much more complex style that displays a selection of images from a gallery, and links to it (this assumes use of the link parameter to define the target web page)
First, a very simple display that just displays the selected image(s) with no links. In this example the header and tail blocks aren't used.
$styleStrings[0]['header']=0; $styleStrings[0]['tail']=0; $styleStrings[0]['image']=<<<IMG <img src='%%file%%' title='%%title%%' alt='%%sdesc%%' class='EGTimage' %%size%%/> IMG;
and a much more complex style that displays a selection of images from a gallery, and links to it (this assumes use of the link parameter to define the target web page)
$styleStrings[2]['header']=" <fieldset style='background-color: white'> <h2 style='top:-18px; left:12px; width:16em; '> <a href='[~%%link%%~]' style='color:white; background:silver;' > %%ptitle%% </a> </h2> %%pdesc%%<br /> <div style='height:140px;'> "; $styleStrings[2]['image']=<<<IMG <span style='float: left; margin: 10px;'> <a href='[~%%link%%~]'> <img src='%%file%%' title='%%title%%' alt='%%sdesc%%' %%size%%/> </a><br /> %%title%% </span> IMG; $styleStrings[2]['tail']=" </div> <div style='clear: both;'> <div style='float: right;'> <a href='[~%%link%%~]'>... visit the %%ptitle%% gallery (%%total%% images)</a> </div> </div> </fieldset> ";











