shadowayex Posted May 5, 2008 Share Posted May 5, 2008 Ok, a few days ago, I saw a cool menu that looked like just a little bar on the side of the window that said "menu". But when you put the mouse over it, the options came in sight. How would I make something like this? I want to add it to a site I'm building, and I also want to add a second one below it for when admins sign in (I'm sure if I learn how to place the menus specifically, I can figure the rest out with PHP. I know enough PHP to create user-based websites.) Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 5, 2008 Share Posted May 5, 2008 Like this? http://www.dynamicdrive.com/dynamicindex1/...slide/index.htm Link to comment Share on other sites More sharing options...
shadowayex Posted May 5, 2008 Author Share Posted May 5, 2008 Yes exactly like that! Thank you! Now, to figure out how to work with it and what not . Link to comment Share on other sites More sharing options...
shadowayex Posted May 5, 2008 Author Share Posted May 5, 2008 I've figured out how to use that. It's working great. But I want to make it so a second one comes up when admins are logged in. Is there any way to do that? (Note: With my site set up, admins are recognized by a field in my SQL database.) Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 5, 2008 Share Posted May 5, 2008 Sure you could. Make a Boolean PHP variable to reflect the SQL field value, then inject it into the JavaScript like so: //JavaScript Documentif(<?= $bool ? 'true' : 'false' ?>){ //show the admin menu} (But make sure the file is set to have the PHP parsed out of it, either by using a PHP extension - I use '.js.php' with a 'text/javascript' content-type - or by configuring the server to parse PHP in '.js' files. On Apache, the latter would be done in either httpd.conf - or apache.conf depending on the version - or a directory-specific .htaccess file.) Link to comment Share on other sites More sharing options...
shadowayex Posted May 6, 2008 Author Share Posted May 6, 2008 @_@ It's like a foreign language . I think I understand, kind of. The deal is, I'm using a free hosting site, so yeah. Not too sure if they have it set to have PHP in .js files and whatnot. Link to comment Share on other sites More sharing options...
Synook Posted May 6, 2008 Share Posted May 6, 2008 The deal is, I'm using a free hosting site, so yeah. Not too sure if they have it set to have PHP in .js files and whatnot.Usually they allow for .htaccess files anyway (while blocking certain directives for security). But just name your JS file .php, no harm. Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 6, 2008 Share Posted May 6, 2008 @_@ It's like a foreign language . I think I understand, kind of. The deal is, I'm using a free hosting site, so yeah. Not too sure if they have it set to have PHP in .js files and whatnot.Heh, yeah, it's kinda hard to get used to echoing source code for a second (semi-)programming language to read. Plus I used compact syntax that isn't as human-readable, so pay attention to where the <?= ?> (which echoes an expression) starts and ends.You probably don't want to parse PHP in all '.js' files unless you frequently use this trick. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.