Login

Tag "link"

Snippet List

Help text hyperlinks

Sometimes a plain-text help-text isn't sufficient, and it's handy to be able to add links to pages, documentation or external websites. This javascript snippet can be added to your page, in combination with adding a class to your help text in your template. This assumes you're using jQuery on your website. Field template snippet: ``` {% if field.help_text %}<p class="help-text">{{ field.help_text }}</p>{% endif %} ``` On document ready, this will convert the markdown-style links into anchor tags, allowing you to have richer help text for your users

  • help
  • link
  • documentation
  • docs
  • href
  • help_text
Read More

Link If templatetag

Django templatetag wraps everything between ``{% linkif %}`` and ``{% endlinkif %}`` inside a ``link`` if ``link`` is not False. Sample usage:: {% linkif "http://example.com" %}link{% endlinkif %} {% linkif object.url %}link only if object has an url{% endlinkif %}

  • link
Read More

Active link

I needed a way to find if a menu items should be active. After searching the internet i found a few options*, but none of them did fit my needs, so i wrote my own: Usage: <a href="{% url 'view-name' %}" class="{% current request 'view-name' %}"></a> * http://gnuvince.wordpress.com/2008/03/19/the-new-and-improved-active-tag/ * http://stackoverflow.com/questions/340888/navigation-in-django

  • template
  • path
  • active
  • link
  • current
Read More

Url persistance of GET variables

I'm using Django 0.96 for a project, and the url tag does not have all the capabilities I need. I want a way to persist all or some of the GET parameters between requests. I also want a way to add to the current url a list of extra parameters, or nullify certain parameters. In this snippet I am defining 2 tags ... link_persist and link_add. It only works with Django 0.96, as the API changed ... but maybe a good soul can fix it for 1.0, as I haven't had any time available. A tip for usage: if you specify a parameter as being the empty string, or None, the parameter will be removed from the link. When you specify a parameter already available in GET, it will replace it.

  • get
  • url
  • link
  • persistance
Read More

Hyperlink list filter

This is a simple filter that takes an object list and returns a comma-separated list of hyperlinks. I use it to display the list of tags in my blog entries. The function assumes the object has a `get_absolute_url()` method that returns the URL. In your template, write `{{ obj_list|hyperlink_list:"slug" }}` where `obj_list` is your object list and `"slug"` is the object's attribute that returns the link text.

  • filter
  • templatetag
  • links
  • template-tag
  • link
  • hyperlink
Read More

html helpers for images and links

link and img are both HTML construction helpers. Good idea to use these helpers if your html don't fit into templates.

  • template
  • image
  • html
  • img-src
  • link
  • a-href
  • construction
  • helper
Read More

7 snippets posted so far.