« Back to zenphoto.org

Template Functions Guide

This is a guide through all functions you can use to build custom themes for zenphoto (new functions since zenphoto 1.1 are marked)


  1. Generic Helper Functions
    1. printLink()
    2. printVersion()
    3. printAdminLink('$text', '$before', '$title', '$class', '$id')
    4. zenJavascript()
    5. set_context()
    6. printSubalbumAdmin($text, $before=, $after=) [1.1]
    7. printAdminToolbox($context=null, $id="admin") [1.1]
  2. Gallery Index (album list) Context
    1. getGalleryTitle()
    2. printGalleryTitle()
    3. getMainSiteName()
    4. getMainSiteURL()
    5. printMainSiteLink('$title', '$class', '$id')
    6. getGalleryIndexURL()
    7. getNumAlbums()
  3. Album AND Gallery Contex
    1. next_album()
    2. getCurrentPage()
    3. getTotalPages()
    4. getPageURL('$page')
    5. hasNextPage()
    6. getNextPageURL()
    7. printNextPageLink('$text', '$title', '$class', '$id')
    8. hasPrevPage()
    9. getPrevPageURL()
    10. printPrevPageLink('$text', '$title', '$class', '$id')
    11. printPageNav('$prevtext', '$separator', '$nexttext', '$class', '$id')
    12. printPageList('$class', '$id')
    13. printPageListWithNav('$prevtext', '$nexttext', '$nextprev', '$class', …
    14. printPageListWithNav('$prevtext', '$nexttext', '$oneImagePage', …
    15. show_sub_count_index()
    16. show_sub_count_index()
    17. getNumSubalbums() [1.1]
    18. getPageURL_($page, $total) [1.1]
    19. getPageURL_($page, $total) [1.1]
  4. Album Context
    1. getAlbumTitle()
    2. printAlbumTitle()
    3. getParentAlbums()
    4. printParentBreadcrumb('$before', '$between', '$after')
    5. getAlbumDate()
    6. printAlbumDate('$before', '$nonemessage', '$format')
    7. getAlbumPlace()
    8. printAlbumPlace()
    9. getAlbumDesc()
    10. printAlbumDesc()
    11. getAlbumLinkURL()
    12. printAlbumLink('$text', '$title', '$class', '$id')
    13. printSortableAlbumLink('$text', '$title', '$class', '$id')
    14. printSortableGalleryLink('$text', '$title', '$class', '$id')
    15. getAlbumThumb()
    16. printAlbumThumbImage('$alt',' $class', '$id')
    17. getCustomAlbumThumb($size, $width, $height, $cropw, $croph, $cropx, …
    18. printCustomAlbumThumbImage('$alt', $size, $width, $height, $cropw, $croph, …
    19. getNextAlbumURL()
    20. getPrevAlbumURL()
    21. getNumImages()
    22. next_image()
    23. getAlbumID()
    24. albumNumber() [1.1]
    25. getParentAlbums() [1.1]
    26. isImagePage() [1.1]
    27. isAlbumPage() [1.1]
  5. Image Context
    1. getImageTitle()
    2. printImageTitle()
    3. getImageDesc()
    4. printImageDesc()
    5. getImageID()
    6. printImageID()
    7. getImageSortOrder()
    8. printImageSortOrder()
    9. hasNextImage()
    10. getNextImageURL()
    11. getPrevImageURL()
    12. printPreloadScript()
    13. getPrevImageThumb()
    14. getNextImageThumb()
    15. getImageLinkURL()
    16. printImageLink('$text', '$title', '$class', '$id')
    17. printImageDiv()
    18. getSizeCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy)
    19. getSizeDefaultImage()
    20. getSizeFullImage()
    21. getDefaultWidth()
    22. getDefaultHeight()
    23. getFullWidth()
    24. getFullHeight()
    25. isLandscape()
    26. getDefaultSizedImage()
    27. printDefaultSizedImage('$alt', '$class', '$id')
    28. getImageThumb()
    29. printImageThumb('$alt', '$class', '$id')
    30. getFullImageURL()
    31. getSizedImageURL($size)
    32. getCustomImageURL($size, $width, $heigh, $cropw, $croph, $cropx, $cropy)
    33. printCustomSizedImage('$alt', $size, $width, $height, $cropw, $croph, …
    34. printSizedImageLink($size, '$text', '$title', '$class', '$id')
    35. imageNumber() [1.1]
    36. getImageDate($format=null) [1.1]
    37. printImageDate($before="Date: ", $nonemessage="", $format="F jS, Y") [1.1]
  6. IPTC, EXIF and video functions
    1. getImageLocation() [1.1]
    2. getImageCity() [1.1]
    3. getImageState() [1.1]
    4. getImageCountry() [1.1]
    5. getImageVideo() [1.1]
    6. getImageVideoThumb() [1.1]
    7. getImageEXIFData() [1.1]
    8. printImageEXIFData() [1.1]
    9. printImageMap($zoomlevel='6') [1.1]
    10. hasMapData() [1.1]
    11. printAlbumMap($zoomlevel='8') [1.1]
  7. Comment Context
    1. getCommentCount()
    2. getCommentsAllowed()
    3. next_comment()
    4. getCommentAuthorName()
    5. getCommentAuthorEmail()
    6. getCommentAuthorSite()
    7. printCommentAuthorLink('$title', '$class', '$id')
    8. getCommentDate('$format ')
    9. getCommentTime('$format' )
    10. getCommentBody()
    11. printEditCommentLink('$text', '$before', '$after','$title', '$class', …
  8. Miscellaneous functions
    1. printAlbumZip() [1.1]
    2. printLatestComments($number) [1.1]
    3. getImageStatistic($number, $option) [1.1]
    4. printImageStatistic($number, $option) [1.1]
    5. printPopularImages($number=5) [1.1]
    6. printLatestImages($number=5) [1.1]
    7. getRandomImages() [1.1]
    8. printRandomImages($number, $class=null, $option="all") [1.1]
    9. getRandomImagesAlbum() [1.1]
    10. my_truncate_string($string, $length) [1.1]
  9. Tag & Image Statistic funcions
    1. getTags() [1.1]
    2. printTags($option="",$preText=NULL,$class='taglist',$separator=", …
    3. getAllTags() [1.1]
    4. printAllTagsAs($option,$class="",$sort="abc",$counter=FALSE,$links=TRUE,$ma …
    5. getAllDates() [1.1]
    6. printAllDates($class="archive", $yearid="year", $monthid="month") [1.1]
    7. getCustomPageURL($page, $q="") [1.1]
    8. printCustomPageURL($linktext, $page, $q="", $prev, $next, $class) [1.1]
    9. getURL($image) [1.1]
    10. getAllSubAlbumIDs($albumfolder=) [1.1]
    11. hitcounter() [1.1]
  10. RSS functions
    1. printRSSLink($option, $prev, $linktext, $next, $printIcon=true, …
    2. printRSSHeaderLink($option, $linktext) [1.1]
  11. Search functions
    1. printSearchForm($prevtext=NULL) [1.1]
    2. getSearchWords($separator=" | ") [1.1]
    3. getSearchDate($format="F Y") [1.1]
  12. Option handling functions
    1. setOption($key, $value, $persistent=true) [1.1]
    2. getOption($key) [1.1]
    3. setOptionDefault($key, $default) [1.1]
    4. OpenedForComments?($what=3) [1.1]
    5. getTheme(&$zenCSS, &$themeColor, $defaultColor) [1.1]
    6. normalizeColumns($albumColumns, $imageColumns) [1.1]


Generic Helper Functions

Usable in all theme files.

Prints the link zenphoto's website www.zenphoto.org.

printVersion()

Prints the version number of the installed ZenPhoto.

printAdminLink('$text', '$before', '$title', '$class', '$id')

Prints a link to administration if the current user is logged-in.

zenJavascript()

Print any Javascript required by zenphoto. Every theme should include this somewhere in its <head>.

set_context()

When using the set_context() function, there are several contexts available to you. They are:

• ZP_INDEX • ZP_ALBUM

?? • ZP_IMAGE

• ZP_COMMENT • ZP_GROUP

Let's take the album context as an example. Themes will have an index.php -- this file shows a listing of all the albums. When you click on one of the albums, you're now using album.php. This is basically what handles the display of the albums page (where all the thumbnails for the images are shown). It is in this file that your context is automatically set to ZP_ALBUM. This allows album.php to have access to all of the functions that affect albums such as getting the album's title, getting the album's date, getting the album's thumbnail, etc. To set context manually, do the following:

... <normal index context code> ...
set_context(ZP_ALBUM);
<album context code>
set_context(ZP_INDEX);
... <resume normal index context code> ...

printSubalbumAdmin($text, $before=, $after=) [1.1]

printAdminToolbox($context=null, $id="admin") [1.1]




Gallery Index (album list) Context

Usable in index.php of your theme.

getGalleryTitle()

Returns the title of the ZenPhoto Gallery without printing it.

printGalleryTitle()

Prints the title of the gallery.

getMainSiteName()

Returns the name of the main website if zenphoto is part of a website without printing it and if added this in zp-config.php..

getMainSiteURL()

Returns the URL of the main website if zenphoto is part of a website without printing it and if added this in zp-config.php..

printMainSiteLink('$title', '$class', '$id')

Prints the URL of the main website if zenphoto is part of a website and if added this in zp-config.php.

getGalleryIndexURL()

Returns the URL of index.php of zenphoto without printing it

getNumAlbums()

Returns the number of albums without printing it.


Album AND Gallery Contex

Common functions shared by Albums and the Gallery Index: WHILE next_album(): context switches to Album. If we're already in the album context, this is a sub-albums loop, which, quite simply, changes the source of the album list. Switch back to the previous context when there are no more albums. Usable in index.php and album.php of your theme.

next_album()

Returns TRUE if there is a next album. Use within If- or while loops for pagination.

getCurrentPage()

Returns the current page if you have several pages in album or index view without printing it

getTotalPages()

Returns the number of pages if you have several pages without printing it

getPageURL('$page')

Returns the URL of a page. Use alway with a variable like getPageURL(1) for the first page for example.

hasNextPage()

Returns TRUE if there is a next page. Use within If- or while loops for pagination.

getNextPageURL()

Returns the URL of the next page.

printNextPageLink('$text', '$title', '$class', '$id')

Prints the URL of the next page. $text: The linktext that should be printed as a link $title: The text the html-tag "title" should contain $class: insert here the CSS-class name you want to style the link with $id: insert here the CSS-ID name you want to style the link with

hasPrevPage()

Returns TRUE if there is a previous page. Use within If- or while loops for pagination.

getPrevPageURL()

Returns the URL of the previous page.

printPrevPageLink('$text', '$title', '$class', '$id')

Prints the URL of the previous page. $text: The linktext that should be printed as a link $title: The text the html-tag "title" should contain $class: Insert here the CSS-class name you want to style the link with $id: Insert here the CSS-ID name you want to style the link with

printPageNav('$prevtext', '$separator', '$nexttext', '$class', '$id')

Prints a page navigation including previous and next page links $prevtext: Insert here the linktext like 'previous page' $separator: Insert here what you like to be shown between the prev and next links $nexttext: Insert here the linktext like "next page" $class: Insert here the CSS-class name you want to style the link with (default is "pagelist") $id: Insert here the CSS-ID name if you want to style the link with this

printPageList('$class', '$id')

Prints a list of all pages like "1 2 3 4" as links. $class: Insert here the CSS-class name you want to style the link with (default is "pagelist") $id: Insert here the CSS-ID name you want to style the link with

printPageListWithNav('$prevtext', '$nexttext', '$nextprev', '$class', '$id')

printPageListWithNav('$prevtext', '$nexttext', '$oneImagePage', '$nextprev', '$class', '$id') [community build]

Prints a full page navigation including previous and next page links with a list of all pages in between. $prevtext: Insert here the linktext like 'previous page'

$nexttext: Insert here the linktext like 'next page'

$oneImagePage: if true emits only one page for the images. Defaults to false. This is used by flash type themes which manage images one one page.

$nextprev: If true prints the <<prev and next>> links. Defaults to true.

$class: Insert here the CSS-class name you want to style the link (default is "pagelist")

$id: Insert here the CSS-ID name if you want to style the link (default NULL)

show_sub_count_index()

Prints the number of the subalbums in the current album

show_sub_count_index()

Prints the number of all subalbums in the gallery

getNumSubalbums() [1.1]

getPageURL_($page, $total) [1.1]

getPageURL_($page, $total) [1.1]




Album Context

Usable in album.php of your theme.

getAlbumTitle()

Returns the title of the current album.

printAlbumTitle()

Prints the title of the current album. If you are logged in you can klick on this to modify the name on the fly.

getParentAlbums()

Returns the parent if you use subalbums. Not fully implemented.

printParentBreadcrumb('$before', '$between', '$after')

Prints the breadcrumb navigation for album, gallery and image view. $before: Insert here the text to be printed before the links $between: Insert here the text to be printed between the links $after: Insert here the text to be printed after the link

getAlbumDate()

Returns the date of the current album

printAlbumDate('$before', '$nonemessage', '$format')

Prints the date of the current album.. $before: Insert here the text to be printed before the date. $nonemessage: ???. $format: Insert here the format like 'F jS, Y'.

getAlbumPlace()

Returns the place of the album.

printAlbumPlace()

Returns the place of the album.

getAlbumDesc()

Returns the album description of the current album.

printAlbumDesc()

Prints the album description of the current album.

getAlbumLinkURL()

Returns the album link url of the current album.

printAlbumLink('$text', '$title', '$class', '$id')

Printss the album link url of the current album. $text: Insert the linktext here. $title: Insert the title text here. $class: Insert here the CSS-class name you want to style the link with. $id: Insert here the CSS-ID name you want to style the link with.

printSortableAlbumLink('$text', '$title', '$class', '$id')

Print a link that allows the user to sort the current album if they are logged in. If they are already sorting, the Save button is displayed $text: Insert the linktext here. $title: Insert the title text here. $class: Insert here the CSS-class name you want to style the link with . $id: Insert here the CSS-ID name you want to style the link with.

printSortableGalleryLink('$text', '$title', '$class', '$id')

Print a link that allows the user to sort the Gallery if they are logged in. If they are already sorting, the Save button is displayed. $text: Insert the linktext here. $title: Insert the title text here. $class: Insert here the CSS-class name you want to style the link with. $id: Insert here the CSS-ID name you want to style the link with.

getAlbumThumb()

Returns the name of the defined album thumbnail image.

printAlbumThumbImage('$alt',' $class', '$id')

Prints the album thumbnail image. $alt: Insert the text for the alternate image name here. $class: Insert here the CSS-class name you want to style the link with. $id: Insert here the CSS-ID name you want to style the link with.

getCustomAlbumThumb($size, $width, $height, $cropw, $croph, $cropx, $cropy)

printCustomAlbumThumbImage('$alt', $size, $width, $height, $cropw, $croph, $cropx, $cropy,'$class', '$id')

getNextAlbumURL()

Returns the URL of the next album in the gallery.

getPrevAlbumURL()

Returns the URL of the previous album in the gallery.

getNumImages()

Returns the number of images in the album.

next_image()

Returns true if there is a next image in the album.

getAlbumID()

Returns the ID of the current album (in an album loop)

albumNumber() [1.1]

gets the n for n of m albums

getParentAlbums() [1.1]

isImagePage() [1.1]

isAlbumPage() [1.1]




Image Context

Usable in image.php of your theme.

getImageTitle()

Returns the title of the current image.

printImageTitle()

Returns the title of the current image.

getImageDesc()

Returns the description of the current image.

printImageDesc()

Prints the description of the current image.

getImageID()

Returns the unique ID of this image.

printImageID()

Prints the unique ID of this image.

getImageSortOrder()

Returns the sort order of this image.

printImageSortOrder()

Prints the sort order of this image

hasNextImage()

Returns TRUE if there is a next image in the current album.

getNextImageURL()

Returns the url of the next image.

getPrevImageURL()

Returns the url of the previous image.

printPreloadScript()

Prints the JavaScript? for preloading images???

getPrevImageThumb()

Returns the thumbnail of the previous image.

getNextImageThumb()

Returns the thumbnail of the next image.

getImageLinkURL()

Returns the url of the current image.

printImageLink('$text', '$title', '$class', '$id')

Prints the link to the current image.

printImageDiv()

Prints the entire <div> for a thumbnail. If we are in sorting mode, then only the image is inserted, if not, then the hyperlink to the image is also added.

getSizeCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy)

getSizeDefaultImage()

Returns an array [width, height] of the default-sized image.

getSizeFullImage()

Returns an array [width, height] of the original image.

getDefaultWidth()

Returns the width of the default-sized image (see printDefaultSizedImage)

getDefaultHeight()

Returns the height of the default-sized image (see printDefaultSizedImage)

getFullWidth()

Returns the width of the original image.

getFullHeight()

Returns the height of the original image.

isLandscape()

Returns TRUE if the image is landscape-oriented (width is greater than height)

getDefaultSizedImage()

Returns the url to the default sized image.

printDefaultSizedImage('$alt', '$class', '$id')

Prints the url to the default sized image.

getImageThumb()

Returns the url to the thumbnail image.

printImageThumb('$alt', '$class', '$id')

Prints the url to the thumbnail image.

getFullImageURL()

Returns the url to original image.

getSizedImageURL($size)

getCustomImageURL($size, $width, $heigh, $cropw, $croph, $cropx, $cropy)

Returns the url to the image in that dimensions you define with this function.

printCustomSizedImage('$alt', $size, $width, $height, $cropw, $croph, $cropx, $cropy, '$class', '$id')

Prints the image in the dimensions you define with this function.

printSizedImageLink($size, '$text', '$title', '$class', '$id')

Prints url to the image in the dimensions you define with the previous function.

imageNumber() [1.1]

getImageDate($format=null) [1.1]

printImageDate($before="Date: ", $nonemessage="", $format="F jS, Y") [1.1]

IPTC, EXIF and video functions

getImageLocation() [1.1]

getImageCity() [1.1]

getImageState() [1.1]

getImageCountry() [1.1]

getImageVideo() [1.1]

ZenVideo?: Return video argument of an Image

getImageVideoThumb() [1.1]

ZenVideo?: Return videoThumb argument of an Image.

getImageEXIFData() [1.1]

printImageEXIFData() [1.1]

Deprecated, name changed.

printImageMap($zoomlevel='6') [1.1]

hasMapData() [1.1]

printAlbumMap($zoomlevel='8') [1.1]




Comment Context

Usable in image.php. Literate through comments; use the ZP_COMMENT context.

getCommentCount()

Returns the number of comments for the current image.

getCommentsAllowed()

Returns if comments are allowed for the current image.

next_comment()

Returns TRUE if there is a next comment.

getCommentAuthorName()

Returns the name of the author.

getCommentAuthorEmail()

Returns the e-mail-adress of the author.

getCommentAuthorSite()

Returns the url of the author's website.

printCommentAuthorLink('$title', '$class', '$id')

Prints the link to the author's website.

getCommentDate('$format ')

Returns the comment date like 'F jS, Y'.

getCommentTime('$format' )

Returns the comment time like 'g:i a'.

getCommentBody()

Returns the comment itself.

printEditCommentLink('$text', '$before', '$after','$title', '$class', '$id')

Prints a link to the link if you are logged in.




Miscellaneous functions

printAlbumZip() [1.1]

printLatestComments($number) [1.1]

getImageStatistic($number, $option) [1.1]

not for standalone use, is used by printLatestImages and printPopularImages

printImageStatistic($number, $option) [1.1]

not for standalone use, is used by printLatestImages and printPopularImages

printPopularImages($number=5) [1.1]

printLatestImages($number=5) [1.1]

getRandomImages() [1.1]

printRandomImages($number, $class=null, $option="all") [1.1]

getRandomImagesAlbum() [1.1]

my_truncate_string($string, $length) [1.1]




Tag & Image Statistic funcions

getTags() [1.1]

printTags($option="",$preText=NULL,$class='taglist',$separator=", ",$editable=TRUE) [1.1]

getAllTags() [1.1]

printAllTagsAs($option,$class="",$sort="abc",$counter=FALSE,$links=TRUE,$maxfontsize="2",$maxcount="50",$mincount="10") [1.1]

$option = "Cloud" for tag cloud, "list" for simple list $class = CSS class $sort = "results" for relevance list, "abc" for alphabetical, blank for unsorted $counter = TRUE if you want the tag count within brackets behind the tag $links = false for no links $maxfontsize = Maximum font size to use in the tag cloud $maxtagcout = Maximum result value to be used $mintagcount = the lowest result value to be used for the cloud

getAllDates() [1.1]

printAllDates($class="archive", $yearid="year", $monthid="month") [1.1]

getCustomPageURL($page, $q="") [1.1]

printCustomPageURL($linktext, $page, $q="", $prev, $next, $class) [1.1]

getURL($image) [1.1]

getAllSubAlbumIDs($albumfolder=) [1.1]

hitcounter() [1.1]




RSS functions

printRSSLink($option, $prev, $linktext, $next, $printIcon=true, $class=null) [1.1]

$option: "Gallery" for RSS for the whole gallery "Album" for currently selected album "Comments" for comments

printRSSHeaderLink($option, $linktext) [1.1]




Search functions

printSearchForm($prevtext=NULL) [1.1]

getSearchWords($separator=" | ") [1.1]

getSearchDate($format="F Y") [1.1]




Option handling functions

setOption($key, $value, $persistent=true) [1.1]

getOption($key) [1.1]

setOptionDefault($key, $default) [1.1]

OpenedForComments?($what=3) [1.1]

called with one parameter which specifies the degeree of control desired IMAGE will return the image level setting ALBUM will return the album level setting the Default, IMAGE+ALBUM will return the AND of the two levels

getTheme(&$zenCSS, &$themeColor, $defaultColor) [1.1]

normalizeColumns($albumColumns, $imageColumns) [1.1]

passed # of album columns, # of image columns of the theme returns # of images that will go on the album/image transition page Updates (non-persistent) images_per_page and albums_per_page so that the rows are filled