Export to GitHub

agroapp - TemplateTags.wiki


Introduction

Agro comes with 2 templatetags, get_latest and format.

Details

  • The first template tag {% get_latest %} is used to retrieve a list of entries. ``` Return a list of entries to your template as a context variable.

    Arguments::

      Limit:    This is the maximum number of entries to return.
    
      Type: This can be a single type, either quoted or not, or a quoted space-delimited list of types. 
          ** USE 'entries' to return all entries **
    
      User: This can be a single user, either quoted or not, or a quoted space-delimited list of usernames. 
          ** DEFAULTS to all users **
    
      Var:  This is the varible you want to use in your template, all found entires are returned to this variable. 
          ** DEFAULTS to 'entry_list' **
    

    Syntax::

      {% get_latest <limit> <type> [[by <user>] as <var>] %}
    

    Usage::

      {% get_latest 5 entries as entries %} OR
      {% get_latest 10 photo as entries %}  OR
      {% get_latest 10 "photo" as entries %}    OR
      {% get_latest 10 "photo bookmark" as marks_and_photos %}  OR
      {% get_latest 100 entries by "camflan" as camflans_stuff %}   OR
      {% get_latest 52 "tweet bookmark" by "camflan drhorrible" as tweets_and_marks %}
    

    ```

  • The second templatetag {% format %} is used to render the object to the page. ``` Used to format an entry for pretty output to the web.

      It will default to using the builtin format_template of the entry's object. 
      Can specify a template or a directory of templates. When specifying a directory, 
      it will look for a template named the same as the name of the object. 
    
      Arguments::
    
          Template: This is can be a specific template file, or a directory. If it's a
                directory, then files in that directory must be named the same as the model.
                example: tweet.html, photo.html, bookmark.html
    
      Syntax::
    
      {% format entry [using <template> [dir]] %}
    
      Usage::
    
      {% format entry %}    OR
      {% format entry using "flickr.html" %}    OR
      {% format entry using "entry_formats" dir %} OR
      {% format entry using "entry_formats/mobile" dir %}
    

    ```