A lot of Qgoda's functionality is available from the Qgoda plug-in. You activate like this in a template:
[% USE q = Qgoda %]
Using the shortcut q
for the plug-in is a well-established convention.
You can then use all methods of the plug-in like this:
[% USE q = Qgoda %]
...
Last generated: [% q.strftime('%c') %].
Many of the following functions expect FILTERS
.
Please see Filters for more information!
Returns a list (an array) of all documents matching FILTERS
.
This is equivalent to calling
q.list()
with the arguments
type = "post"
.
Returns a list (an array) of all posts matching FILTERS
.
This is equivalent to calling q.list()
with
the arguments type = "post"
.
Virtual methods are methods that are directly applied to a variable by adding a dot and the method invocation, for example:
The slugs of '[% asset.title | html %]' is '[% asset.title.slugify() %]'.
The Qgoda plug-in extends the list of standard vmethods in Template Toolkit by a number of useful methods:
The following methods are available on arrays:
Sorts the array alpha-numerically by the property specified. The call
q.listPosts.sortBy('date.year')
would sort all posts by their
year. It is wrong to specify asset.date.year
because the objects
returned by q.listPosts()
are all assets. You have to specify the
key, the object property.
Same as sortBy()
but sorts numerically. For example "2" is
numerically less than "10", but alpha-numerically greater than "10" because
the digit "2" is alphanumerically greater than "1" just as the letter
"b" is alphanumerically greater than "a".
When applied to an array of objects (hashes), it returns the values of
the property specified by the string argument. For example
q.listPosts.vmap('permalink')
gives you an array of the
permalink
attribute of all posts.
The following methods are available on hashes (also known as objects in JSON or JavaScript or formally as associative arrays):
Like vmap()
above but the collection is a hash. The values
are visited in alphanumerical order or their corresponding keys.