[WM] duplicate code

Robert Echlin Robert at OfficeProfessor.CA
Tue Apr 13 02:19:17 IST 2004


Hi,
I am working on using webmake to reproduce my current corporate site:
http://www.officeprofessor.ca
so I can expand it easily.

I was creating the pages manually, including the left side main 
navigation area, with non-linked text when the link in the bar is to the 
current page.

I have used perl code in the sitemapnode and sitemapleaf to accomplish 
this (below).
My  questions for the group are:
- Is there a way to do this with existing Webmake funtionality without 
perl code?
- How do I store my duplicated perl code, so it is not duplicated?
 - Is this worth the effort of figuring out how to create a new module?
 - Or can someone add this functionality to an existing module?

I expect to use this technique in my wife's newest web site (not up yet 
- it'll be a math site) which will initially have (I think) two levels 
of areas in the site map - top level and .the contents of various areas. 
I also expect to use Webmake on her current main site: 
www.hogwartsalumni.com.

Thanks.
Robert

Sample code placed in the public domain.

<template name=sitemapnode>
     <p>
 <{perl
 my $page = expand('${WebMake.OutName}') ;
 my $name = expand('${name}') ;
 $name =~ s/\.txt$// ;
 if ($page eq $name) {
   $_ = '<span class="button" >' ;
   $_ .= expand('${title}') . '</span> <br />' ;
 }
 else {
   $_ = '<a class="button" href="' . expand('$(url)') . '">' ;
   $_ .= expand('${title}') . '</a> <br />' ;
 }
 $_;
 }>
      ${list} </p>
</template>

<template name=sitemapleaf>
 <{perl
 my $page = expand('${WebMake.OutName}') ;
 my $name = expand('${name}') ;
 $name =~ s/\.txt$// ;
 if ($page eq $name) {
   $_ = '<span class="button" >' ;
   $_ .= expand('${title}') . '</span> <br />' ;
 }
 else {
   $_ = '<a class="button" href="' . expand('$(url)') . '">' ;
   $_ .= expand('${title}') . '</a> <br />' ;
 }
 $_;
 }>
</template>




-- 
Robert Echlin, B.Eng.
President, Office Professor Inc.
613-266-8311       Robert [at] OfficeProfessor.CA
www.OfficeProfessor.CA




More information about the Webmake-talk mailing list