Gossamer Forum
Home : Products : Links 2.0 : Customization :

Internal Links only?

Quote Reply
Internal Links only?
Is it possible to set up Links 2.01 for linking to internal pages only?

I would like to be able to set it up so that pages on the same site are linked to by the system. I am not sure if the detailed pages option would do that - I haven't been able to find out how it actually works using a search here.

Basically, I'm trying to set it up for somebody who doesn't know HTML. They need to be able to create pages using a form, and then link to them from the Links directory. The easier it is from their point of view, the better. DBMan does some of that, but wouldn't really allow them the flexibility to add graphics etc. (I also don't think it is made for searching and browsing by visitors from what I saw of the demo).

It seems a bit of a waste to have a full URL like www.theirdomain.com/Loads/Of/Other/Directories/Details/specific.html when the file is only one directory away from the category.

The answer is probably staring me right in the face, but I am so used to seeing it used for external links I am just not seeing it.


Quote Reply
Re: Internal Links only? In reply to
The DBMAN demos are not representative of how many users are applying the script. The login screen can be bypassed, and more fields can be added, etc.

Anyway... You can do internal linking. Detailed pages are the easiest, but to save disk space, use info.cgi, which builds the pages dynamicly. You need to edit jump.cgi, near the bottom where it has something like "Location: $goto\n\n" to the point to static pages or info.cgi.

--Drew
Quote Reply
Re: Internal Links only? In reply to
Well the structure of the thing needs to be organized into categories like Links displays so that users can browse their way to the information.

Basically, this part of the site will be like a yellow pages, and there will be single detailed pages for every link at the outermost branches of the category tree.

Some may only have a name and address, whilst others will have an image, a review or a map on the page. This won't affect the way Links works though as once the user reaches the detailed page it won't be involved again unless they need to look for another match.

The structure for each page would be something like:-

Country/State/Town/Company_Type/Details/companyname.html

Is that how detailed pages get added or do they all get dumped in a directory called 'Detailed' off the main directory? (Like Cool and New).

There will be several hundred of these links so it wouldn't be a good idea for them to all end up together like that.


Quote Reply
Re: Internal Links only? In reply to
Yeah, the details pages all get placed in the same directory. I recall that someone attempted to build the details pages in the category where they belong but I don't know if a solution was found.

--Drew
Quote Reply
Re: Internal Links only? In reply to
Okay, so it looks as if using an external program to create the detailed pages would be easiest.

Is there an easy way of using relative rather than absolute links as URLs? i.e. just using Details/companyname.html instead of http://www.domain.com/Country/State/Company_Type/Details/companyname.html if the link is from the Company_Type category?

It would sure cut down on typing and the database size if that were possible (without major code hacking I mean).


Quote Reply
Re: Internal Links only? In reply to
Again, you have two options, and either way, you don't need anything in your URL field, because the your links are based on your ID field:

1)
Use static pages and modify jump.cgi to point to them instead a URL.

2)
Installing my info.cgi hack. Modify jump.cgi to point to info.cgi to build the pages dynamicly.

Codes for both of these methods have been provided serveral times in the forum.

--Drew
Quote Reply
Re: Internal Links only? In reply to
Thanks. I will try another search here (obviously I'm using the wrong keywords).

My efforts at adapting the script are hampered by the fact that my host seems to cache requests to the server, so it takes a while for any modifications I make to the files to actually affect anything after the files are sent via FTP.

Btw, a good 50% or more of matches on a search consist of messages with an answer of "do a search" :o)


Quote Reply
Re: Internal Links only? In reply to
In Reply To:
Btw, a good 50% or more of matches on a search consist of messages with an answer of "do a search" :o)
That's because too many users post new topics rather than using the resources already available.

--Drew
Quote Reply
Re: Internal Links only? In reply to
I've looked through the resources until my eyes were sore and tried as many different keywords as I could think of, but couldn't find any mention of how to modify the script so that it will accept links without the http:// part at the beginning.

The problem is that all the links will be internal, and I am setting this up on my own host. The whole thing will be moved to another host later, so absolute links would be a pain.

Normally I would just try playing with the script myself, but it seems my connection (and not my host as I previously thought) caches files at present. This is a glitch in the network which is supposedly being looked into, but doesn't help me any right now.

If I make any changes to the script configuration the effects are delayed because the old version is used.

Very frustrating Crazy

Can somebody please point me in the right direction, or at least narrow my search down?

Here is a quick recap of what I am trying to do:-

* Create a directory of internal/relative links all in the format of /Details/companyname.html relative to the category they are listed in.
* Link to static pages created with a separate script (the detailed option builds in one directory which is not a good idea for several thousand pages).
* Have the whole setup as easy to use as possible for someone (else) with no knowledge of how websites work.
* Only use CGI for the database building and searching, not the linking/displaying of pages to keep CPU use down.

The person who I am trying to set this up for will most likely upgrade to Links SQL later, but at present this is a startup site with a very low budget. It will have a large number of pages, but very little traffic at first. It also isn't intended to be a commercial venture.


Quote Reply
Re: Internal Links only? In reply to
Okay, after much head scratching and staring at bits of code I think I have thought of a way to do this, though I'm not sure what code to change to do it:-

1. Turn detailed mode on.
2. Add the path to the current category to the detailed build path so they get built there instead of in the root.
3. Remove the URL reference totally from the links and give them a plain text title instead.
4. Use the detailed option to create the detailed pages.

I am not sure how to do step 2 though (step 4 is a little hazy too).

Would changing the values for $build_detail_path and $build_detail_url in links.cfg be enough? What would they be changed to?


Quote Reply
Re: Internal Links only? In reply to
Here's how to get your link details where you wanted them.

In nph-build.cgi, change sub build_detailed_view to:
Code:
sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $count);

print "\t";
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
if ("$build_root_path/$rec{'Category'}/Detailed" =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
open (DETAIL, ">$build_root_path/$rec{'Category'}/Detailed/$id$build_extension") or &cgierr ("Unable to build detail page: $build_root_path/$rec{'Category'}/Detailed/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_root_url/$rec{'Category'}/Detailed/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}
In sub build_dir, change:
Code:
print "\tMaking Directory ($build_dir_per): '$build_root_path$path' ...";
to:
Code:
print "\n\tMaking Directory ($build_dir_per): '$build_root_path$path' ...";
The second change is optional. It makes the printout a bit more legible.

If you're using templates (site_html_templates.pl), then your link url in links.html should look like:
Code:
<%build_root_url%>/<%Category%>/Detailed/<%ID%><%build_extension%>
or in site_html_link, change:
Code:
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
to:
Code:
detailed_url => "$build_root_url/$rec{'Category'}/Detailed/$rec{'ID'}$build_extension",
and use the <%detailed_url%> tag instead.

If you're using non-templates (site_html.pl), then change the following line in site_html_link:
Code:
($output = qq~<ul><li><a class="link" href="$build_detail_url/$rec{$db_key}$build_extension">$rec{'Title'}</a>~) :
to:
Code:
($output = qq~<ul><li><a class="link" href="$build_root_url/$rec{'Category'}/Detailed/$rec{$db_key}$build_extension">$rec{'Title'}</a>~) :
Changed 3-Sept-00
-re:http://www.gossamer-threads.com/p/103574

--Drew
Quote Reply
Post deleted by junko In reply to
Quote Reply
Re: Internal Links only? In reply to
Thank you for that Drew, it seems to have solved the problem nicely, it's much appreciated. Smile

The most confusing part of 'switching on' the detailed option for the first time is that it doesn't affect the look of the admin section at all. The only effect you see is the extra stage when building. It isn't immediately obvious that you need to add new fields to the form and change the templates to edit the content for the detailed pages. It defaults to repeating the description from the main category.

I was sort of expecting a new link on the menu or an extra field in the forms (that only shows when $build_detailed=1).

Is there a list of variables used in the script anywhere so that I don't inadvertently use an existing one for new fields? Or are they all listed in the .def and .cfg files, including temporary variables?


Quote Reply
Re: Internal Links only? In reply to
In Reply To:
It defaults to repeating the description from the main category.
Do you mean it prints the category description if the links' description isn't set?


--Drew
Quote Reply
Re: Internal Links only? In reply to
No, it prints whatever the description for the site/link is, as shown in the main category listing.

Which is a little on the pointless side, as that info was obviously already shown there.

I'm thinking that I need to add a long_description field to the database and show that in the detailed view instead. Unless I'm missing something somewhere.


Quote Reply
Re: Internal Links only? In reply to
Ah...yeah that makes better sense. You had me worried for a minute there Frown.

--Drew
Quote Reply
Re: Internal Links only? In reply to
I haven't managed to mess it up that badly - yet. Wink

It kind of makes sense - in a way. I imagine that the intention is that you remove the description from the standard view and only show it in the detailed view.

I'd still rather have a short description in the main view though.

Wonder if I could adapt the URL field for that as there won't be any external links. 75 characters should be more than enough.


Quote Reply
Re: Internal Links only? In reply to
You can just add another field to your database instead of going through the mess of trying to get those unused fields to cooporate.

--Drew
Quote Reply
Re: Internal Links only? In reply to
Yeah, I guess you're right.

I'll reduce the length of it though I think - maybe set it to 8 characters and leave it to default to the normal "http://" (not sure if there's a null character at the end, so 8 would be safer than 7 - I've had C programs go *bink* at me in the past for that).


Quote Reply
Re: Internal Links only? In reply to
Thanks for the Mod. It was just what I was looking for.

I seem to have one problem with it though. The delete function doesn't delete the detailed text file. I'm a newbie with Links, but I can't even find the code where Links would delete the html file if it were in the original place.



Kirk


Quote Reply
Re: Internal Links only? In reply to
Try changing the permissions. If that doesn't work, then do a search for a script in the cgi/perl forum called something like 'wipe out'.

--Drew
Quote Reply
Re: Internal Links only? In reply to
Permissions are fine. The one thread I found with the text "wipe out" in it doesn't seem to have anything to do with this situation. Here's the link. http://www.gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=L2Unix&Number=20437&page=&view=&sb=&vc=1

Can anyone confirm that Links 2 does actually delete the detailed html text file? I cannot find the code where it is deleted and the variable which points to the detailed directory "$build_detail_path" only shows up in the build_detailed_view subroutine.

Kirk

Quote Reply
Re: Internal Links only? In reply to
If you had searched the cgi/perl forum like I suggested than you would have found the script.
Get it here:http://www.cybernox.com/scripts/wipeout.html

Links 2.0 does not have any delete functions so you need to use third-party scripts, modifications, and file management programs to remove the files.

--Drew