Tom (xtomxfallsx) wrote in component_help,
Tom
xtomxfallsx
component_help

Tags List & Redirector

Note: Do not bother commenting on this post to ask for help. I will not respond. Make a new post instead.
This will add a component with a dropdown box containing tags on all of the entries a viewer has access to on your journal with the ability to select a tag and view all entries tagged with it.

This code will need to go within a component function, such as print_free_text(Page p).


############################################
# LiveJournal Tags List and Redirector     #
# by lj:kunzite1, posted by lj:xtomxfallsx #
############################################ 

 var string      k1TRheader    = "Tags In This Journal"; # set the component header text, you can change this to whatever you want
 var string      k1TRbutton    = "Go"; # button text, change it to whatever you want
 var bool        k1TRblank     = true; # set to true to create a blank option at top the list, or false not to
 # No need to change anything below this line (unless you know what you are doing!)
 
 var string      k1TRbase_url  = $p.journal->base_url(); 
 var string      k1TRcontent   = "";
 var TagDetail[] k1TRtags      = $p->visible_tag_list();

 foreach var TagDetail k1TRtag ($k1TRtags) {
  $k1TRcontent = $k1TRcontent + """<option value="$k1TRtag.name">$k1TRtag.name</option>\n""";
 }

 print_comp_header($k1TRheader); # print the component header
 """

 <div class="compContent">

  <form action="$k1TRbase_url/" method="get">
   <select id="tags_select" name="tag"> """;
   if($k1TRblank) {
    """<option value="" selected="selected"></option>\n""";
   }
   print $k1TRcontent; """
   </select><br />
   <input type="submit" value="$k1TRbutton" />
  </form> 
 
 </div>""";

 print_comp_footer(); # print the component footer


A Warning: If you have a lot of tags on your journal, this component can sometimes cause LJ to have trouble displaying your journal style because the code will die if it takes too long to run. Usually a page refresh will remedy the situation. Just be aware.
Tags: !tutorial, *account level: paid/perm, function: print_free_text, user: xtomxfallsx
Subscribe

  • Custumizing the new spam button in the comment link bar

    Hi everyone. LJ recently added a "spam" button in the comment linkbar. I use a tutorial to display my own images instead of the standard LJ buttons,…

  • Tutorials, etc.

    Since a prior maintainer of this community felt it necessary to delete all the entries about how to actually do things (ahem) help can be obtained by…

  • Sidebar as Topbar

    Name: marilla_pm67 Account: Permanent I would like to modify a layout I already have : - This is the live preview - This is the…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 1 comment