/    Sign up×
Community /Pin to ProfileBookmark

Linking with CSS dropdowns…

Hi, I’m trying to create a CSS based dropdown menu (suckerfish menu), and have kind of hit a road block when it comes to linking. Because I have my site set up with folders, I can’t see how I will be able to use the same html for each page and still have the links work correctly. Because I want to put the menu in a template which I will use on all the pages, but since the pages are all in different folders, the links will screw up.

Example!

index.html is not in a folder
Folder1 contains file1.html and file1a.html
Folder2 contains file2.html and file2a.html
etc.

When I want to link to file1.html, I could put in <a href=”file1.html”>. This will work fine if I am on page file1a.html or anywhere within Folder1. But if I am on page file2.html or anywhere NOT in folder1, I would have to put something like <a href=”../folder1/file1.html”> and then that won’t work if you are not in a folder, for example on the index page.

I had this problem back when I was using javascript for the menu, but solved it by creating a variable called baseHref which made all links absolute…but obviously I can’t do the same thing here. So would I actually have to have go through and type out the entire absolute links for every one in order for it to work?

to post a comment
CSS

13 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 14.2005 — Hi!

You could use absolute paths (the 'full business': href="http://www.mysite.com/myfolder/myfile.html").

Cheers - Pit

Edit: Ooops - I read your post again (until the end) and I have to admit: my post is garbage. Sorry for that.
Copy linkTweet thisAlerts:
@hooloovoo24authorFeb 14.2005 — *sigh* I was afraid someone would say that. I don't like doing that for reasons not even I know...but I guess you gotta do what you gotta do, so, thanks!
Copy linkTweet thisAlerts:
@TriumphFeb 14.2005 — [i]Originally posted by hooloovoo24 [/i]

[B]*sigh* I was afraid someone would say that. I don't like doing that for reasons not even I know...but I guess you gotta do what you gotta do, so, thanks! [/B][/QUOTE]
Eh??
Copy linkTweet thisAlerts:
@PittimannFeb 14.2005 — Hi!

You could at least avoid having to type the domain stuff by using:

href="/myfolder/mynestedfolder/myfile.html"

Better than nothing. ?

Cheers - Pit
Copy linkTweet thisAlerts:
@hooloovoo24authorFeb 14.2005 — [i]Originally posted by Triumph [/i]

[B]Eh?? [/B][/QUOTE]


Nevermind. I'm tired.
Copy linkTweet thisAlerts:
@David_HarrisonFeb 14.2005 — Do you have any server-side languages available? You could do something similar to what you did with the JavaScript menu. If you have a server-side language available then I'll elaborate a bit further, if you use ASP I could even write the function for you, if you use PHP then get out of my sight. :p
Copy linkTweet thisAlerts:
@mikepurvisFeb 14.2005 — [i]Originally posted by Pittimann [/i]

[B]href="/myfolder/mynestedfolder/myfile.html"[/B][/QUOTE]


This is what I do. Once you get into mod_rewrite territory (which there's no excuse to not do, if you're on apache), you pretty well have to.
Copy linkTweet thisAlerts:
@breunorFeb 15.2005 — I use SSI include to put my navigation menu on every page, thus I have just the one text file to edit and I'm done. I also use relative links, which requires a BASE reference in each page using the menu: <BASE href="http://www.webpage.net"> Then all your relative links start from that point, regardless of where your web page is. You can even move them to a new web site if you want! The BASE declaration needs to go into the header. This is a very simple solution, nothing fancy is needed.
Copy linkTweet thisAlerts:
@David_HarrisonFeb 15.2005 — <base> is now depreciated though. To be honest I don't see what the problem is with just using /directory/file.html it'll work on every page.
Copy linkTweet thisAlerts:
@hooloovoo24authorFeb 15.2005 — [i]Originally posted by lavalamp [/i]

[B]Do you have any server-side languages available? You could do something similar to what you did with the JavaScript menu. If you have a server-side language available then I'll elaborate a bit further, if you use ASP I could even write the function for you, if you use PHP then get out of my sight. :p [/B][/QUOTE]


Umm...I think I have ASP but I'm not sure. How would I find this out?
Copy linkTweet thisAlerts:
@David_HarrisonFeb 15.2005 — Well, your host should just tell you. But if not, give this a whirl, save as a .asp file and upload it:&lt;%@ language="VBscript" %&gt;
&lt;% option explicit %&gt;
&lt;%= "Hi" %&gt;
If you only see Hi when you run the page it works, if you see the whole she-bang, then it doesn't.
Copy linkTweet thisAlerts:
@hooloovoo24authorMar 03.2005 — OK...sorry this has been so long, and i'm dredging this thread up from godknowswhere, but it is what it is. I've been so busy with other crap that I haven't had time to deal with this yet. But now I can. So...I DO have ASP but I have no clue how to use it...so if anyone wants to help me...?
Copy linkTweet thisAlerts:
@hooloovoo24authorMar 17.2005 — [i]Originally posted by David Harrison [/i]

[B]<base> is now depreciated though. To be honest I don't see what the problem is with just using /directory/file.html it'll work on every page. [/B][/QUOTE]


Well, if I do that, I won't be able to test it until it is online, right? because I'd have to put in... http://www.site.com/whatever or something, wouldn't I? Or am I getting this wrong?

PS sorry for again dredging this up, but I'm desperate for a solution here, so please someone help me before I annoy us all to death!
×

Success!

Help @hooloovoo24 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...