Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How to extract the TOP level dir

Quote Reply
How to extract the TOP level dir
I am setting up a site for registered commercial use of Links 2 but I need to extract the TOP level dir from (for example) the category_linked variable. What I need to do is extract the dir name, add .gif to it and add that graphic to the current category page. Any help would be GREATLY appreciated and is the only thing holding my project off. I will register the software as soon as I get it all going. (Even if I have to use some sort of work around)...

Thanks in advance for your help!
Quote Reply
Re: How to extract the TOP level dir In reply to
Anyone have any help on this one? PLEASE?

Thanks in advance!

Joe
Quote Reply
Re: How to extract the TOP level dir In reply to
The TOP link you see is generated in nph_build.cgi in sub build_linked_title it is referenced to the $build_root_url which is referenced in links.cfg to your pages directory.
To change it to display a grahic instead of TOP place your <img src="route_to_graphic.gif"> where the TOP currently is.

chmod
Quote Reply
Re: How to extract the TOP level dir In reply to
Thanks Chmod BUT,

Each of my graphics is different based AND named by the top level category. Is that what you meant?

Joe
Quote Reply
Re: How to extract the TOP level dir In reply to
Joe,

In your original thread, you said you were trying to extract your top-level directory. In your last post, you said top-level category. They are not the same, so which is it you want to know about?
Quote Reply
Re: How to extract the TOP level dir In reply to
Sorry!

When I referred to "dir" in the initial post I was referring to the variable "dir" which I believe is the directory of the category.

What I really need is the top level category name only so that I can add ".gif" to it and put that specific image on the current page.

The scenario:

A top level for each state in the US and each state's category has 26 (A-Z) sub categories and then each of those can have numerous additional sub-categories. I want to put the graphic associated with the state on each of the pages under each state. Right now I am having to duplicate the graphic in each folder which is a real disk space hog.

Thanks for your help!

Joe


[This message has been edited by JoeWebb (edited August 08, 1999).]
Quote Reply
Re: How to extract the TOP level dir In reply to
Look at the code in nph-build.cgi, sub build_linked_title. There is a line in it that reads:

Quote:
$output = qq| <A HREF="$build_root_url/">Top</A> :|;

That is were the URL is formed for the Top but that top is for the Home Page, not the category page. What follows it is for the category pages. So, you wouldn't be able to just put and image in place of Top because it would always be the home page. The first directory after it is the top-level directory and your image there would look odd.

Of course, you could always remove that Top line and just show the directories instead, with the first one being your graphic link. You would need a series of if-elsif-else statements that would check to see if $path is equal to each top-level category in order to display the correct graphic.

I hope this helps.

Quote Reply
Re: How to extract the TOP level dir In reply to
Close,

I don't want to modify the linked list, just create the name of an image from the top-level-category/directory. For example, for category Virginia/A/Alexandria, I need to extract Virginia from the category and add .gif to it creating Virginia.gif and subsequently load that image (a flag of Virginia) and put it somewhere on that page.

It sounds as if the $path variable might be the best option? I'm not a perl programmer, just OLD Pascal, so I don't know what the heck I'm doing..<grin>

Thanks for your help!
Joe
Quote Reply
Re: How to extract the TOP level dir In reply to
Any reason you don't just use the header field? If you put in the header field for each state:

<img src="/images/California.gif">

then put <%header%> where you want it to appear it should work.

Cheers,

Alex
Quote Reply
Re: How to extract the TOP level dir In reply to
Thanks Alex!

I tried using the header field but couldn't figure out how to make it work. I was using or rather trying to use an external file name in the field and all I ever got was the external filename on my pages. Guess I should have figured out what was happening.

Thanks again!

Joe