diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:28:09 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:28:09 +0000 |
| commit | abcf997713fe87a68c8ce7035c9e9dc2266145ea (patch) | |
| tree | 46ef96ac38d39316f618c43652f7f8b4b6d588d2 /docs | |
| parent | 936c99b7c745a3e104d274f6e0dabb68e3086ca0 (diff) | |
Fixed #11100 - Added get_comment_permalink template tag to comments app to be able to customize the anchor pattern of a comment from the template. Thanks to Idan Gazit for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12080 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/comments/index.txt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/ref/contrib/comments/index.txt b/docs/ref/contrib/comments/index.txt index 54fb7a192d..f66d14d0c4 100644 --- a/docs/ref/contrib/comments/index.txt +++ b/docs/ref/contrib/comments/index.txt @@ -104,6 +104,44 @@ This returns a list of :class:`~django.contrib.comments.models.Comment` objects; see :ref:`the comment model documentation <ref-contrib-comments-models>` for details. +.. templatetag:: get_comment_permalink + +Linking to comments +------------------- + +To provide a permalink to a specific comment, use :ttag:`get_comment_permalink`:: + + {% get_comment_permalink comment_obj [format_string] %} + +By default, the named anchor that will be appended to the URL will be the letter +'c' followed by the comment id, for example 'c82'. You may specify a custom +format string if you wish to override this behavior:: + + {% get_comment_permalink comment "#c%(id)s-by-%(user_name)s"%} + +The format string is a standard python format string. Valid mapping keys +include any attributes of the comment object. + +Regardless of whether you specify a custom anchor pattern, you must supply a +matching named anchor at a suitable place in your template. + +For example:: + + {% for comment in comment_list %} + <a name="c{{ comment.id }}"></a> + <a href="{% get_comment_permalink comment %}"> + permalink for comment #{{ forloop.counter }} + </a> + ... + {% endfor %} + +.. warning:: + + There's a known bug in Safari/Webkit which causes the named anchor to be + forgotten following a redirect. The practical impact for comments is that + the Safari/webkit browsers will arrive at the correct page but will not + scroll to the named anchor. + .. templatetag:: get_comment_count Counting comments |
