The following instructions are for Links 2.0 users who wish to have the home page created in their root directory but have all other files created in a subdirectory.
|
STEP 1: Open links.cfg
a) FIND
# Paths and URL's to Important Stuff # -------------------------------------------------------- # PATH and URL of Admin CGI directory. No Trailing Slash. $db_script_path = "/full/path/to/cgi-bin/links/admin"; $db_dir_url = "http://www.yourdomain.com/cgi-bin/links/admin"; # URL of User CGI directory. No Trailing Slash. $db_cgi_url = "http://www.yourdomain.com/cgi-bin/links"; # PATH and URL of Pages to be built. No Trailing Slash. $build_root_path = "/full/path/to/links"; $build_root_url = "http://www.yourdomain.com/links"; |
b) ADD THE FOLLOWING IMMEDIATELY BENEATH
# PATH and URL of Default Index Page to be built. No Trailing Slash. $build_default_path = "/full/path/to/root/directory"; $build_default_url = "http://www.yourdomain.com"; |
Be sure to edit the code to reflect the paths on your server.
STEP 2: Open nph-build.cgi
a) FIND sub build_home_page. EDIT THE SUBROUTINE REPLACING ALL THREE INSTANCES OF $build_root_path with $build_default_path:
sub build_home_page { # -------------------------------------------------------- my ($subcat, @rootcat); local ($total); # Check to see which categories are off of the root. foreach $subcat (sort keys %category) { if ($subcat =~ m,^([^/]*)$,) { push (@rootcat, $subcat); } } print "\tSubcategories: "; print $#rootcat+1; print "\n"; print "\tTotal Links: $grand_total\n"; print "\tOpening page: $build_default_path/$build_index\n"; open (HOME, "$build_default_path/$build_index") or &cgierr ("unable to open home page: $build_default_path/$build_index. Reason: $!"); $category = &site_html_print_cat (@rootcat) if ($#rootcat >= 0); $total = $grand_total; print HOME &site_html_home; close HOME; print "\tClosing page.\n"; } |
b) FIND sub build_linked_title. EDIT THE SUBROUTINE REPLACING ONLY THE FIRST OCCURRENCE OF $build_root_url with $build_default_url:
sub build_linked_title { # -------------------------------------------------------- # Returns a string of the current category broken up # by section, with each part linked to the respective section. my $input = shift; my (@dirs, $dir, $output, $path, $last); @dirs = split (/\//, $input); $last = &build_clean(pop @dirs); $output = qq| <A HREF="$build_default_url/">Top</A> :|; foreach $dir (@dirs) { $path .= "/$dir"; $dir = &build_clean ($dir); $output .= qq| <A HREF="$build_root_url$path/">$dir</A> :|; } $output .= " $last"; return $output; } |
c) FIND sub build_staggered, and scroll to the bottom of that subroutine where you will find the following code. EDIT THE CODE REPLACING $build_root_url with $build_default_url. I also like to replace target="_top" with target="_blank" because I like to have my site loaded in a new window, leaving the admin screen in its own window.
my $elapsed = time() - $start; print "------------------------------------------------\n"; print qq~Step 4 took $elapsed seconds.\n\n<b><a href="$build_default_url" target="_top">Your site</a> is now up to date!</b>~; last CASE; }; |
d) FIND sub build_all. In it find the following section, then EDIT THE CODE REPLACING $build_root_url with $build_default_url.
# Create Home Page $use_html ? print qq|Building <A HREF="$build_default_url/$build_index">Home Pages</A> . . .\n| : print qq|Building Home Page . . .\n|; &build_home_page; print "\tDone\n\n"; |
STEP 3: OPEN admin_html.pl
a) FIND sub html_top
In that subroutine find the link to your home page and replace $build_root_url with $build_default_url.
While you're there, you might want to change target="_top" to target="_blank". I do this because I like to have my home page open in a new window so that I don't have to press the back button to return to the admin screen.
b) If you use templates find sub html_template_help, otherwise skip to step 5.
In that sub find:
<p>By default you can use the following codes: <ul><li><%date%> - Current date. <li><%time%> - Current time. <li><%db_cgi_url%> - URL to your user cgi directory. <li><%build_root_url%> - URL to your user home directory. <li><%site_title%> - Title of your Links directory. <li><%css%> - URL to your links.css file. </ul> |
and replace
with<li><%build_root_url%> - URL to your user home directory.
<li><
%build_default_url%>
- URL to your user home directory.
STEP 4: If you use templates open site_html_templates.pl, otherwise skip to step 5.
a) in the %globals section find:
build_root_url => $build_root_url,
and add this line directly underneath:
build_default_url => $build_default_url,
b) edit every one of your template files and replace
<a class="menulink" href="<%build_root_url%>">Home</a> |
with
<a class="menulink" href="<%build_default_url%>">Home</a> |
Be sure that you edit only the "Home" link and not the links for Add, Modify, New, Cool, etc.
Note: Rather than having all the menu code repeated in each template, it is more elegant to put the menu code in a separate text file which you can call into each of your templates with an <%include%> tag. To do this you must first install Alex's Enhanced Template Support Mod.
c) Skip Step 5. You are done.
STEP 5: If you don't use templates, open site_html.pl
a) In the Globals section, find the global $site_menu and replace
<a class="menulink" href="$build_root_url">Home</a> |
with
<a class="menulink" href="$build_default_url">Home</a> |
Be sure that you edit only the "Home" link and not the links for Add, Modify, New, Cool, etc.