NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page A handy bit of code

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 08-20-2006, 06:54 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




A handy bit of code


Lets say, you let each user choose a theme, and the url of the css for that theme was stored in a database. If you are using dreamweaver and want your pages to look nice (ie: WITH a style sheet) while you edit them, use this code.

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/code/229683-a-handy-bit-of-code.html
if(== 2){
?>
<head>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<?php
}else{
     echo 
'<head>
     <link rel="stylesheet" href="' 
$url_to_stylesheet '" type="text/css" />
     </head>'
;
}
?>
How this works is:
1) Dreamweaver sees the HTML and renders it.
2) The PHP parser sees the if statement if(1 == 2), 1 does not equal 2, so the html is not rendered.
3) Because 1 does not equal 2, the alternate style sheet is used instead.

Basicly, it uses your stylesheet when your editing it in dreamweaver, but another stylesheet when online.
Barrucadu is offline  
Old 09-07-2006, 05:42 AM   #2 (permalink)
Account Suspended
Join Date: Jan 2005
Posts: 139
lepunk is an unknown quantity at this point
 



hehe! tricky code usefull if you are using dreamweaver...
...but I'm using notepad..or programmers notepad
lepunk is offline  
Old 09-07-2006, 09:04 AM   #3 (permalink)
NamePros Regular
 
ablaye's Avatar
Join Date: May 2006
Location: WebmasterGround.com
Posts: 865
ablaye is on a distinguished road
 



Thanks for the code. Very useful indeed.
ablaye is offline  
Old 09-08-2006, 11:48 AM THREAD STARTER               #4 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Originally Posted by lepunk
usefull if you are using dreamweaver...
Yup, I got bored of trying to edit big pages with no stylesheet, lol
Barrucadu is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:54 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger