How to read the Zenphoto Functions Guide Apr 15, 2008 / Updated: Dec 29, 2014
When you first look at our functions guide it might look confusing and you may not understand what exactly it is telling you. You might ask "why don't they just write an understandable and readable guide that even non-developers can understand at first glance?" Well, actually the guide is not that hard to read once you get into it.
We are constantly updating and changing things, so that would take too much of our time write a guide manually. If one of us writes or changes a new function, he comments it within the source code directly on top of the function. You might have seen that if you looked at the template-functions.php file for example. We then use the standard auto-documentation tool phpDocumentor that generates the functions guide from these source code's comments. This way we can easily update it with one click anytime we need to.
So let's take a closer look at one of the more complicated template functions as an example now: printAllTagsAs() from template-functions.php:
This is the list of parameters the function provides for your theme customizing needs. There are three "fields" for each parameter.
- The type of parameter value you can enter for the variable. These are the common types:
- string for a textstring. Value to be entered within quotes.
- bool for TRUE or FALSE. Value to be entered without quotes.
- int for integer numbers'. Value to be entered without quotes.
- obj for an object. Value is a variable containing the object of the required type, e.g. $_zp_current_album.
- The name of the variable.
- The description of what values to do what.
This is the actual important part. You can ingnore the "void", that is not important and added by the phpdocumentor because it does not know better... ;-) Important are the options within the brackets. If you look closely you will notice that this is actually the same as the parameter list above. In short this would read:
printAllTagsAs($option, $class = '', $sort = 'abc', $counter = FALSE,$links = TRUE, $maxfontsize = 2, $maxcount = 50, $mincount = 10, $limit = NULL)
For example $sort = 'abc' is a default value that is used if no other value is entered for this parameter. To use this function within your theme to print a tag cloud you would have to write simply this:
This would print:
- a tag cloud
- without a css class for styling
- "abc" for alphabetical sorting
- no tag count within brackets behind the tag
- no search tag links
- largest font size the cloud should display set to 2
- the maximum count for a tag to appear in the output set to 50
- the minimum count for a tag to appear in the output set to 10
- set to limit the number of tags displayed to the top $numtags disabled.
If you only want to set specific parameters, you have to set all others inbetween, too. For example: If you want to set only the parameters $option and $counter you have to set the parameters $class and $sort as well as they are inbetween and can't be left out even if they have default values as described above.
This is only possible if they are the last ones that are not specifially set. So the function call would look like this if you only set the $option parameter:
The parameters after $option can be left out if their default values will be used.
Hopefully this makes it easier for you to understand the documentation.
This text by www.zenphoto.org is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Code examples are released under the GPL v2 or later license