Sir Brettley (sir_brettley) wrote in component_help,
Sir Brettley

  • Mood:

Fixing the problem with '+' character in tag URLs; repost of free text tag component code

The problem is cause by LiveJournal mangling the tag.url property. You can bypass this by constructing your own URL to reference tags:

var string url_base = $p.journal->base_url() + "/tag/";

Note that depending on where you are in the code, you may not have to reference $p (which assumes you are in the free text component and have been passed the page context via the $p variable) but something else (see Kunzite1's post on tags for another example).

You then combine the url_base with the tag name to make the complete url:

<a href="$url_base$">$</a>

Where $t refers to a variable of type TagDetail. Since the "name" property of the tag preserves the spaces, there is no problem with the URL.

Remember that there are different ways of displaying tags. You can display them in entries, in a free text component, in a sidebar and as part of the new "tag page". Each one has its value, and you can use more than one!

I will post the free text component version again here to reduce email to the innocent user in the other post ;)

Note that some of the code is commented out. This is because components are too narrow to display all of the tag data. Pick for yourself what you'd like to display. Note that by calling "visible_tag_list()" each user gets a list of only those tags they are allowed to see. You do not have to filter them!

Also kunzite1 has his own excellent version of a component/sidebar tag list. If you already use his code I recommend you use his version for compatibility across all your code.

If you have problems with the code post here or email/IM me.

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened