The Qgoda Plug-In

Functions provided by the Qgoda Plug-In

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') %].

Methods

Many of the following functions expect FILTERS. Please see Filters for more information!

q.list(FILTERS)

Returns a list (an array) of all documents matching FILTERS. This is equivalent to calling q.list() with the arguments type = "post".

q.listPosts(FILTERS)

Returns a list (an array) of all posts matching FILTERS. This is equivalent to calling q.list() with the arguments type = "post".

Virtual Methods

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:

Virtual Array Methods

The following methods are available on arrays:

sortBy()(string)

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.

sortBy(string)

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".

vmap(string)

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.

Virtual Hash Methods

The following methods are available on hashes (also known as objects in JSON or JavaScript or formally as associative arrays):

vmap(string)

Like vmap() above but the collection is a hash. The values are visited in alphanumerical order or their corresponding keys.

This website uses cookies and similar technologies to provide certain features, enhance the user experience and deliver content that is relevant to your interests. Depending on their purpose, analysis and marketing cookies may be used in addition to technically necessary cookies. By clicking on "Agree and continue", you declare your consent to the use of the aforementioned cookies. Here you can make detailed settings or revoke your consent (in part if necessary) with effect for the future. For further information, please refer to our Privacy Policy.