Darkelve Posted July 19, 2006 Report Share Posted July 19, 2006 I want to retrieve an URL in a string like www.mypage.com/about/ (the string would be 'about') and then applying an 'if' block to it if it matches a certain condition. See following code I have up to now: Dim page page = Request.ServerVariables("url") Response.write (page) ' for testing if page="about" Then Reponse.write("Match Found!") ' for testing - to be replaced with a 'select ... case'-type block end if The idea is to apply a custom background-image through CSS (by applying a class or id with associated style), so that visitors can visually see the main section they are in. Now I'd like to know how I can manipulate the string to capture everything between the first and second 'forward slash' ( / ) and put it in the 'page' variable. I also know a little bit of Basic (Qbasic, Visual Basic) and I was wondering if VBscript has something like a "Select... case" statement. This would be useful in this case, since there are about 9-12 main navigation links to go through. Thanks in advance, Darkelve Quote Link to comment Share on other sites More sharing options...
phunni Posted July 19, 2006 Report Share Posted July 19, 2006 You shouldn't need to do much string manipulation - I think there may well be a method for pulling the about of the URL anyway... There is in java - although I can't remember what it is off the top of my head... Basically if www.mypage.com/ maps to a particular page then you can simply strip off the entire URL (minus query string) after than point. But - wouldn't it be easier to have it as a query parameter: www.mypage.com?style=about You could then simply pull the "style" parameter off the incoming request parameters... To my mind it would be a much simpler approach... Quote Link to comment Share on other sites More sharing options...
Darkelve Posted July 19, 2006 Author Report Share Posted July 19, 2006 (edited) "Basically if www.mypage.com/ maps to a particular page then you can simply strip off the entire URL (minus query string) after than point." Well, what I need to know is how to strip everything between the first "/" (forward slash) and the second "/" (forward slash) and put it in a string variable. Problem is I know next to zero about ASP string manipulation. "But - wouldn't it be easier to have it as a query parameter: www.mypage.com?style=about You could then simply pull the "style" parameter off the incoming request parameters... To my mind it would be a much simpler approach..." Yes, that would be easier, but I can't do that: this is for an existing site consisting of about 200 mostly "static" pages. Edited July 19, 2006 by Darkelve Quote Link to comment Share on other sites More sharing options...
Darkelve Posted July 19, 2006 Author Report Share Posted July 19, 2006 I finally found a solution... I found a new best friend: the "Split" function :) Quote Link to comment Share on other sites More sharing options...
phunni Posted July 19, 2006 Report Share Posted July 19, 2006 Yes, that would be easier, but I can't do that: this is for an existing site consisting of about 200 mostly "static" pages. But if every request went via your ASP (which presumably it has to anyway for anything you do here to work...?) then you could still pull it off the request... Quote Link to comment Share on other sites More sharing options...
tyme Posted July 19, 2006 Report Share Posted July 19, 2006 i could show you how to do this in PHP...but i don't know ASP. it's probably pretty similar - i use a "split" function of sorts too. Quote Link to comment Share on other sites More sharing options...
Darkelve Posted July 19, 2006 Author Report Share Posted July 19, 2006 (edited) It's okay... I solved it, and it works... it's a bit hack-ish, but quite cool to see: - address: www.mysite.com/about/ - ASP 'URL request' and split function used to get the 'about' - each link of the main menu also has an ID with the same name as the current folder (in this example 'id=about') - through ASP, an if-loop (select case, for those who know that) is done and different CSS rules can be applied for all link elements. Here it's just used to put a background image behind the navigation link, so visitors can see what section they're in. By the way, I'm learning PHP (PHP & MySQL to be exact) at the moment... I'm through with ASP... developing in ASP automatically means higher hosting costs... so I feel my time is better spent with PHP (which runs on M$ server OS'es too). And with MySQL you don't need an extra SQL database license... i could show you how to do this in PHP...but i don't know ASP. it's probably pretty similar - i use a "split" function of sorts too. Edited July 19, 2006 by Darkelve Quote Link to comment Share on other sites More sharing options...
tyme Posted July 19, 2006 Report Share Posted July 19, 2006 i used the same sort of trick here - except i used the data in the url to determine the content. Quote Link to comment Share on other sites More sharing options...
Darkelve Posted July 19, 2006 Author Report Share Posted July 19, 2006 Cool... another CSS and web 'experiments' addict ;) Nice CSS-based 'tabbed' navigation buttons I'm currently over my head in learning books... - PeachPitt Press' The Zen of CSS (book about CSS Zen Garden): never thought about 'design' in this way before. - Sams's PHP and MySQL Development... reads like a train... - Lynda.com's Adobe Photoshop CS2 for the web... - about a dozen of online videos and tutorials For starters... I'm in over my head, but I like it this way B) Quote Link to comment Share on other sites More sharing options...
neddie Posted July 19, 2006 Report Share Posted July 19, 2006 s/percieve/perceive/g ;) I'm in over my head, but I like it this way :D Quote Link to comment Share on other sites More sharing options...
phunni Posted July 19, 2006 Report Share Posted July 19, 2006 I'm sorry - but I really don't understand why neither of you didn't simply use request parameters? It would have been much easier... I must be missing something here... Quote Link to comment Share on other sites More sharing options...
tyme Posted July 19, 2006 Report Share Posted July 19, 2006 - PeachPitt Press' The Zen of CSS (book about CSS Zen Garden): never thought about 'design' in this way before.I actually have that book on my shelf right now. Along with Learn AJAX in 10 Minutes and the CSS Pocket Guide. Nice CSS-based 'tabbed' navigation buttonsty :) - took me a while to get it just right. i'm also using CSS "sprites" for the links on the left side of the page s/percieve/perceive/gI know, I know. I never fixed that. I blame mysti, I had it spelled "Perceive" and she told me it was wrong. This page was actually a project for a class, and one of the students pointed it out to me... The whole page is CSS/XHTML/PHP/SQL based. It's still not really "live", though the one band member wants me to help him find a host and get the site up and running. I'm sorry - but I really don't understand why neither of you didn't simply use request parameters? It would have been much easier... I must be missing something here... Because it looks pretty in the address bar :P It's the same thing that mediawiki does - for me it was a user interface design thing, by not having a bunch of confusing variables in the address bar the user could more easily see where they were within the webpage and how they got there. I know, it's a bit over-done since the tabs and links on the left indicate it too - but in UID you have to assume users are dumb ;) Quote Link to comment Share on other sites More sharing options...
Darkelve Posted July 19, 2006 Author Report Share Posted July 19, 2006 (edited) "I actually have that book on my shelf right now. Along with Learn AJAX in 10 Minutes and the CSS Pocket Guide." That reminds me: I still need to find a book or reference about using Photoshop effects for web graphics: for example, something talking about gradients, text effects, buttons, backgrounds, edges, ... do you know of some good ones? (haven't had time yet to look at "Adobe Photoshop CS2 for the web" ... but I bought Photoshop&ImageReady 6 Hands-On-Training and it was good but too 'basic' [e.g. by know I already know how to create a tiling background image, thank you...], so I'm afraid this one will be the same)... some kind of 'recipe' book. Edited July 19, 2006 by Darkelve Quote Link to comment Share on other sites More sharing options...
tyme Posted July 19, 2006 Report Share Posted July 19, 2006 I don't use photoshop...I use GIMP, and everything I know from it I pretty well learned on my own or through some of the tutorials at deviantart.com btw, you should try using the quote function :P [quote]whatever you're quoting from someone who posted[/quote] it works better than parantheses ;). And, with Fast Reply, if you highlight the text you want to quote then mouse over the box...it'll even give you an option to "Add Selected Text As Quote" ;) Quote Link to comment Share on other sites More sharing options...
spinynorman Posted July 19, 2006 Report Share Posted July 19, 2006 And, with Fast Reply, if you highlight the text you want to quote then mouse over the box...it'll even give you an option to "Add Selected Text As Quote" Thanks, tyme. I never knew that. :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.