Taylor made Scripts and Mods!

Mod to create multiple column layout for link listings.

This mod will allow you to enter how many columns you want for you link listings.
It is an update to the ' 2 column link listing '
This mod is for Links 2.
example:

    listing A | listing B | listing C
    listing D | listing E | listing F

see sample page - mainstop.com/i/Shopping/Lingerie

Three files will need to be edited;
nph-build.cgi
category.html
links.cfg

In links.cfg under "Build Options" add $columns = 4;   # number of columns

In category.html find

    <!-- Links in this category. -->
    <%if links%>
        <h2>Links: </h2>
        <%links%>
    <%endif%>
now add;

<!-- Links in this category. -->
    <%if links%>
        <h2>Links: </h2>
        <table width=100%>
        <%links%>
        </table> 
    <%endif%>          

In nph-build.cgi under sub build_category_pages find the lines;
  # If we are spanning pages, we grab the first x number of links and build
  # the main index page. We set $numlinks to the remaining links, and we remove
  # the links from the list.
Now add the lines of code that are blue;
=====copy below====================================================================
# If we are spanning pages, we grab the first x number of links and build
# the main index page. We set $numlinks to the remaining links, and we remove
# the links from the list.
        
        $links .= "<tr>"; 
        $c_i = 0; 

        $numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
        $next = $prev = $links = "";
        if (($numlinks > $build_links_per_page) && $build_span_pages) {
            $page_num = 2;
            $next  = $url . "more$page_num$build_extension";

# added 03-14-01 multi column layout for link listings
            
            for ($i = 0; $i < $build_links_per_page; $i++) {
                %tmp = &array_to_hash ($i, @{$links{$cat}});

                   if ($c_i == $columns) {
                      $links .= qq|</tr>\n<tr>|;
                      $c_i = 0;
                   }
                   $links .= "<TD width=50% valign=top>\n";
                   $links .= $c_i;  
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                   $c_i++; 
                

            }
            $links .= "</tr>\n"; 

            @{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
            $numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);
        }
# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
        else {
           
            for ($i = 0; $i < $numlinks; $i++) {
                %tmp = &array_to_hash ($i, @{$links{$cat}});

                   if ($c_i == $columns) {
                      $links .= qq|</tr>\n<tr>|;
                      $c_i = 0;
                   }       
                   $links .= "<TD width=50% valign=top>\n";       
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                   $c_i++; 
                
                
            }
         $links .= "</tr>\n"; 
        }

# Create the main page.
        open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
            print CAT &site_html_category;
        close CAT;

# Then we go through the list of links and build on the remaining pages.
        $prev = $url if ($build_span_pages);        
        while ($next && $build_span_pages) {
            if ($numlinks > $build_links_per_page) {
                $next_page = $page_num+1;
                $next = $url . "more$next_page$build_extension";
            }
            else {
                $next = "";
            }

            $links = "";

            $c_i = 0;
            $links .= "<tr>"; 

            LINK:  for ($i = 0; $i < $build_links_per_page; $i++) {
                %tmp = &array_to_hash ($i, @{$links{$cat}});
                last LINK if ($tmp{$db_key} eq "");

                   if ($c_i == $columns) {
                      $links .= qq|</tr>\n<tr>|;
                      $c_i = 0;
                   }       
                   $links .= "<TD width=50% valign=top>\n";
                   $links .= $c_i;       
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                   $c_i++; 
                
              
            }
         $links .= "</tr>\n"; 
======copy above==========================================================================
----make sure to paste above these lines --------
$use_html ?
                print qq|\tSubpage  : <A HREF="|, $url, qq|more$page_num$build_extension" TARGET="_blank">$dir/more$page_num$build_extension</A>\n| :
                print qq|\tSubpage  : $dir/more$page_num$build_extension\n|;
                
            open (CAT, ">$dir/more$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
                print CAT &site_html_category;
            close CAT;

In the works

Multi-column links listing enhanced - allows you to enter number of columns in the links.cfg file and the script will automaticly make the columns.

Multi-column and row links listing - this is cool. You'll be able to choose how many columns AND rows you want to appear on each page.




mods and scripts !!!


mainstop.com   |   Cabin rentals    | Mainstop Vacation Rentals