<merlyn> I actually wrote something like this recently </merlyn>

I implemented this through the use of a CGI script and a patched Template Toolkit installation. This patch to the Template Toolkit was to add support for bitwise AND and XOR operations into templates - This patch can be found here and has been submitted to Andy Wardley for consideration for incorporation into the Template Toolkit distribution. This code made the development of this Folder Tree functionality quite easy and can be demonstrated temporarily here.

The CGI script employed is quite simple:

#!/usr/bin/perl -Tw use CGI; use CGI::Carp qw/ fatalsToBrowser /; use Template; use strict; my $cgi = CGI->new; my $index = 0; if ( defined $cgi->path_info ) { my $path = substr( $cgi->path_info, 1 ); $index = $1 if $path =~ /^(\d+)$/; } my $template = Template->new({ 'INCLUDE_PATH' => '/http/development.co +wsnet.com.au/templates' }); my $html = ''; $template->process( 'navigation.tt2', { 'index' => $index }, \$html ) || croak( 'main:: - Cannot process output template - ', $template->e +rror ); print STDOUT $cgi->header, $html; exit 0;

The corresponding template file can be found here - The integer value passed to this CGI script as additional path information is employed through the use of bitwise operations in the template in the following fashion:

<tr> <td bgcolor="#eeeeee" style="padding:2px 4px 2px 4px;" onMouse +Out="this.style.backgroundColor='#eeeeee';" onMous eOver="this.style.backgroundColor='#cbcbe8';"> <font face="Arial" style="font-size:8pt;"><b><a href="/cgi-b +in/navigation.cgi/[% index ^ 1 %]" style="text-dec oration:none;">Access Control</a></b></font><br> </td> </tr> [% IF index & 1 %] <tr> <td bgcolor="#aaaaaa"><img src="/images/spacer.gif" border="0" + height="1" width="1" alt="" /></td> </tr> . . [% END %]

The bitwise AND and XOR operations are used to test the expansion/collapse state of the folder tree and the switching of integer bits respectively.

 

perl -e 'print+unpack("N",pack("B32","00000000000000000000000111101110")),"\n"'


In reply to Re: Folder Tree functionality in perl. Does it exist? by rob_au
in thread Folder Tree functionality in perl. Does it exist? by tachyon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.