[25842] in Perl-Users-Digest
Perl-Users Digest, Issue: 8078 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 13 21:05:21 2005
Date: Fri, 13 May 2005 18:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 13 May 2005 Volume: 10 Number: 8078
Today's topics:
Perl generated navigation menu <spam@noreply.org>
Re: Perl generated navigation menu <nospam@bigpond.com>
Re: Perl generated navigation menu <john@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 14 May 2005 01:17:01 +0000
From: michael <spam@noreply.org>
Subject: Perl generated navigation menu
Message-Id: <d63cj5$7qh$02$1@news.t-online.com>
I'm doing a site which will have a navigation menu in the form of an
unordered list, containing groups of URLs and corresponding link names,
which may be defined in simple arrays, eg.:
@flora_and_funa_URLs = ("z0.html","z1.html","z2.html");
@flora_and_funa_Names = ("Flora & Funa", "Pretty Flowers", "Deadly Vines");
@aquatic_creatures_URLs = ("z3.html","z4.html","z5.html");
@aquatic_creatures_Names = ("Aquatic Creatures","Pretty Fish","Don't Eat");
My idea of a perl script would be to generate the menu including some class
variables, and to serve the following functions:
1. Assign a relevant class value to each LI for CSS to provide visual
indication of which section and page is currently on view.
2) Use a suitable for a large site and easy to maintain menu, which can be
generated directly on html pages through SSI for example.
Separate from Perl and HTML; CSS declarations may style a drop menu
whereby nested UL groups would appear on hover of each complete link group
on CSS aware browsers, whilst Lynx type browsers would interpret only
barebone code, eg.:
<ul>
<li><a href="z0.html">Flora & Funa</a>
<ul>
<li><a href="z1.html">Pretty Flowers</a></li>
<li><a href="z2.html">Deadly Vines</a></li>
</ul>
</li>
<li><a href="z3.html">Aquatic Creatures</a>
<ul>
<li><a href="z4.html">Pretty Fish</a></li>
<li><a href="z5.html">Don't Eat</a></li>
</ul>
</li>
</ul>
But all <li>'s would also include either of 3 classes depending on which
URL is accessed:
<li class="in_group"> <-- in which group user access a page
<li class="this_URL"> <-- the current URL on view
<li class="no_match"> <-- if current URL is the group or page
If a user accesses z4.html for example, the html for its current group would
appear as follows:
<li class="in_group"><a href="z3.html">Aquatic Creatures</a>
<ul>
<li class="this_URL"><a href="z4.html">Pretty Fish</a></li>
<li class="in_group"><a href="z5.html">Don't Eat</a></li>
</ul>
</li>
Whilst all LI's of the other group(s) would then have the <li
class="no_match"> assigned.
It is obviously necessary know which URL is accessed, and as URLs may or may
not include www, https etc., it may be easier to reduce URLs to their
filename substrings and compare that with what's in each of the arrays.
Nested <ul> would need to open after the first closing </a> of the first
<li> which in turn would not close until after the last </ul> for each link
group in order to form the nested UL structure.
As a non-perl scripter I have some likely basic questions:
How can a current URL or filename portion be accessed in Perl?
Are there any modules that may be useful in this example, or would it
perhaps be easier to write a script for the purpose?
In which ways could all be easily done?
Any ideas including code snippets (or chunks) would be greatly appreciated,
especially with regards to transforming the above arrays into the
examplified html structure, perhaps by using a for loop?
Many thanks,
Michael
--
The only way to keep your health is to eat what you don't want, drink what
you don't like, and do what you'd rather not.
-- Mark Twain
------------------------------
Date: Sat, 14 May 2005 09:39:52 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Perl generated navigation menu
Message-Id: <42853b87_1@x-privat.org>
michael wrote:
> I'm doing a site which will have a navigation menu in the form of an
> unordered list, containing groups of URLs and corresponding link names,
> which may be defined in simple arrays, eg.:
>
> @flora_and_funa_URLs = ("z0.html","z1.html","z2.html");
> @flora_and_funa_Names = ("Flora & Funa", "Pretty Flowers", "Deadly
> Vines");
>
> @aquatic_creatures_URLs = ("z3.html","z4.html","z5.html");
> @aquatic_creatures_Names = ("Aquatic Creatures","Pretty Fish","Don't
> Eat");
>
> My idea of a perl script would be to generate the menu including some
> class variables, and to serve the following functions:
>
> 1. Assign a relevant class value to each LI for CSS to provide visual
> indication of which section and page is currently on view.
>
> 2) Use a suitable for a large site and easy to maintain menu, which can be
> generated directly on html pages through SSI for example.
>
> Separate from Perl and HTML; CSS declarations may style a drop menu
> whereby nested UL groups would appear on hover of each complete link group
> on CSS aware browsers, whilst Lynx type browsers would interpret only
> barebone code, eg.:
>
> <ul>
> <li><a href="z0.html">Flora & Funa</a>
>
> <ul>
> <li><a href="z1.html">Pretty Flowers</a></li>
> <li><a href="z2.html">Deadly Vines</a></li>
> </ul>
>
> </li>
>
> <li><a href="z3.html">Aquatic Creatures</a>
>
> <ul>
> <li><a href="z4.html">Pretty Fish</a></li>
> <li><a href="z5.html">Don't Eat</a></li>
> </ul>
>
> </li>
> </ul>
>
>
> But all <li>'s would also include either of 3 classes depending on which
> URL is accessed:
>
> <li class="in_group"> <-- in which group user access a page
> <li class="this_URL"> <-- the current URL on view
> <li class="no_match"> <-- if current URL is the group or page
>
> If a user accesses z4.html for example, the html for its current group
> would appear as follows:
>
> <li class="in_group"><a href="z3.html">Aquatic Creatures</a>
>
> <ul>
> <li class="this_URL"><a href="z4.html">Pretty Fish</a></li>
> <li class="in_group"><a href="z5.html">Don't Eat</a></li>
> </ul>
>
> </li>
>
> Whilst all LI's of the other group(s) would then have the <li
> class="no_match"> assigned.
>
> It is obviously necessary know which URL is accessed, and as URLs may or
> may not include www, https etc., it may be easier to reduce URLs to their
> filename substrings and compare that with what's in each of the arrays.
>
> Nested <ul> would need to open after the first closing </a> of the first
> <li> which in turn would not close until after the last </ul> for each
> link group in order to form the nested UL structure.
>
> As a non-perl scripter I have some likely basic questions:
>
> How can a current URL or filename portion be accessed in Perl?
I esentially do what you ask with www.pchq.com.au
If you use Apache as your webserver, the environment variables REQUEST_NAME,
SERVER_NAME, SCRIPT_NAME and SCRIPT_FILENAME will tell you what's
executing.
But you rarely need to use them.
> Are there any modules that may be useful in this example, or would it
> perhaps be easier to write a script for the purpose?
There are modules like HTML::Template or CGI.pm
http://search.cpan.org/dist/CGI.pm/CGI.pm
However, the more modules you load the slower your cgi runs.
On the web, speed isn't everything, its the ONLY thing.
> In which ways could all be easily done?
I use a database (eg mysql containing your data; a loop; and a print
statement.
> Any ideas including code snippets (or chunks) would be greatly
> appreciated, especially with regards to transforming the above arrays into
> the examplified html structure, perhaps by using a for loop?
It really is as simple as a loop & print statement. You can go down the
route of using templates if you want.
> Many thanks,
> Michael
>
gtoomey
------------------------------
Date: 14 May 2005 01:00:59 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Perl generated navigation menu
Message-Id: <Xns9655CB96EE52Ecastleamber@130.133.1.4>
Gregory Toomey wrote:
> However, the more modules you load the slower your cgi runs.
> On the web, speed isn't everything, its the ONLY thing.
Early optimizing can be a nice way to shoot yourself in the foot.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8078
***************************************