Taylor made Scripts and Mods!

Mod to create 2 column layout for link listings.

This mod is for Links 2.
example:

    listing A | listing B
    listing C | listing D

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

Two files will need to be edited;
nph-build.cgi
category.html


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;
same file in text format - 2_column_link_listings.txt

# 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.
        $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 01-14-01 2 column layout for link listings 'mainstop.com'
            $column_2 = "0";
            for ($i = 0; $i < $build_links_per_page; $i++) {
                %tmp = &array_to_hash ($i, @{$links{$cat}});
                if ($column_2 ne "1") {
                   $column_2 = "1";
                   $links .= "<TR><TD width=50% valign=top>\n";        
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                }
                else {
                   $column_2 = "0";
                   $links .= "<TD width=50% valign=top>\n";       
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD></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 {
            $column_2 = "0";
            for ($i = 0; $i < $numlinks; $i++) {
                %tmp = &array_to_hash ($i, @{$links{$cat}});        
                if ($column_2 ne "1") {
                   $column_2 = "1";
                   $links .= "<TR><TD width=50% valign=top>\n";       
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                }
                else {
                   $column_2 = "0";
                   $links .= "<TD width=50% valign=top>\n";    
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD></TR>\n";
                }
              
            }
          if (int($numlinks/2) != ($numlinks/2)) { $links .= "<td></td></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 = "";
            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 ($column_2 ne "1") {
                   $column_2 = "1";
                   $links .= "<TR><TD width=50% valign=top>\n";       
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD>\n";
                }
                else {
                   $column_2 = "0";
                   $links .= "<TD width=50% valign=top>\n";    
                   $links .= &site_html_link (%tmp);
                   $links .= "</TD></TR>\n";
                }
              
            }
          if (int($numlinks/2) != ($numlinks/2)) { $links .= "<td></td></TR>\n"; } 




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   |      | Mainstop Vacation Rentals