GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Jan-2006, 19:45
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,628
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice
Unhappy

Changing PHP list link color


Not sure how to fix this one. I have a dynamically generated navigation bar and I want to change the default link color. Right now it's the standard blue/purple link colors but I can't figure out how to make the colors change.

I've tried changing the .css file the php script accesses but that only changes the bullet colors; apparently because the list is dynamically made it doesn't "understand" CSS.

Here's the CSS file:
CSS Code:
.box {
	width: 140px;
	margin-top: 3px;
	padding: 0 0 0 0;
	border: 1px solid #000;
	background-color: #999966;

}

.box h3 {
	color: #27282A;
	border-bottom: 1px solid #000;
	padding-left: 2px;
	padding-right: 2px;
	margin: 0 0 0 0;
	background-color: #809966;
}

.box ul {
	margin: 0 0 0 10px;
	padding: 0 0 0 10px;
}

.box ul ul {
	margin: 0 0 0 7px;
	padding: 0 0 0 7px;
}

.box p {
	padding: 3px;
	margin: 2px 0px 2px 0;
	text-align: center;
}

.box a img {
	border: 0px;
	margin: 2px;
}

.rssbutton {
    margin-left: 5px;
}

.breadcrumbs {
    font-size: 80%;

}

.extendedinfo {
    color: gray;
}

Here's the PHP file I'm using:
PHP Code:

<!-- <alexpounds:noList /> -->

<?

include_once($_SERVER["DOCUMENT_ROOT"] . "/gfFunctions.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/userinfo.php");

function buildInnerNav($currentPath) {
    global $myExtension;
    $file = getCurrentFile($currentPath, FALSE);
    $dir = getCurrentDir($currentPath);
    $pathDir = $_SERVER["DOCUMENT_ROOT"] . $dir;
    $parentPath = getParentDir($currentPath);

    if ($dir != "/") {
        buildOuterNav($parentPath, $currentPath, TRUE, 0);
    }
    
    if ($dir !== FALSE && $file !== FALSE) {
        if ($dh = opendir($pathDir)) { // Open directory.
            echo "<ul>\n";
            // If we're in the root, add a "Home" link as we discard the index file in the loop below.
            if ($dir == "/") { 
                if ($file == "index." . $myExtension) {
                    echo "<li><b>Home</b></li>\n";
                } else {
                    echo "<li><a href=\"/\">Home</a></li>\n";
                }
            }
            while (false !== ($currentFile = readdir($dh))) { // Iterate over files in directory one by one.
                $fullPath = $pathDir . "/" . $currentFile;
                // If it's not a dotfile, ., .., the index, AND if it's a PHP file, an HTML file, or a directory, AND it's a file without
                // an <alexpounds:noList /> tag or it's a directory without an alexpounds.noList file, examine it.
                if ((!preg_match("%^\.%", $currentFile) && $currentFile != ".." && !preg_match("%index\.%", $currentFile)) &&
                    (preg_match("%\.php$%", $currentFile) || preg_match("%\.html?$%", $currentFile) || is_dir($fullPath)) &&
                    ((is_file($fullPath) && !hasNoListTag($fullPath)) || (is_dir($fullPath) && !hasNoListFile($fullPath)))) {
                    if ($dir != "/") {
                        $docRootPath = $dir . "/" . $currentFile;
                    } else {
                        $docRootPath = "/" . $currentFile;
                    }
                    
                    //If the current file under consideration is the same as the current file being viewed by the user, output bold text.
                    if ($currentFile == $file) {
                        $currentName = getPageName($fullPath);
                        echo "<li><b>" . $currentName . "</b></li>\n";
                    } else if (is_dir($fullPath)) {
                        echo "<li><a href=\"" . $docRootPath. "\">" . getDirName($docRootPath) . "</a></li>\n";
                    }  else {
                        $currentName = getPageName($fullPath);
                        echo "<li><a href=\"" . $docRootPath . "\">" . $currentName . "</a></li>\n";
                    }
                }
            }
            echo "</ul>\n";
        }
    }
    if ($dir != "/") {
        buildOuterNav($parentPath, $currentPath, FALSE, 0);
    }
}

function buildOuterNav($buildPath, $currentPath, $before, $level) {
    global $myExtension;
    $file = getCurrentFile($currentPath, FALSE);
    $currentParentPath = getCurrentDir($currentPath);
    $parentPath = getParentDir($buildPath);
    $pathDir = $_SERVER["DOCUMENT_ROOT"] . $buildPath;
    
    // We use before to toggle the output, so it only builds the start of the list if being called before the existing one, 
    // And only builds the end of the list if being called after the existing one.
    if ($before) {
        $output = TRUE;
    } else {
        $output = FALSE;
    } 

    // If we're not building the root, and are being called before the list, build the list for the directory above this one.
    if ($buildPath != "/" && $output) {
        buildOuterNav($parentPath, $buildPath, TRUE, $level+1);
    }

    if ($file !== FALSE) {
         if ($dh = opendir($pathDir)) { // Open the directory. 
             if ($output) { // If it's the start, then output an opening list tag. 
                 echo "<ul>\n";
                 if ($buildPath == "/") {
                     echo "<li><a href=\"/\">Home</a></li>\n";
                 }
             }
             while (false !== ($currentFile = readdir($dh))) { // Iterate over each entry in the directory. 
                 $fullPath = $pathDir . "/" . $currentFile;
                 // If it's not a dotfile, ., .., and not an index file, AND it's a PHP file, an HTML file, or a directory, 
                 // AND it's a file with no <alexpounds:noList /> tag or it's a directory with no alexpounds.noList file, 
                 // consider it. 
                 if ((!preg_match("%^\.%", $currentFile) && $currentFile != ".." && !preg_match("%index\.%", $currentFile)) &&
                     (preg_match("%\.php$%", $currentFile) || preg_match("%\.html?$%", $currentFile) || is_dir($fullPath)) && 
                     ((is_file($fullPath) && !hasNoListTag($fullPath)) || (is_dir($fullPath) && !hasNoListFile($fullPath)))) {
                     
                     // Build a path from the docroot. 
                     if ($buildPath != "/") {
                         $docRootPath = $buildPath . "/" . $currentFile;
                     } else {
                         $docRootPath = "/" . $currentFile;
                     }

                     // If it's an index file, and we're currently looking at its containing directory, we want a no-link bold output.
                     if ($file == "index." . $myExtension && $docRootPath == $currentParentPath && $level == 0) {
                         if ($output) {
                             echo "<li><b>" . getDirName($docRootPath) . "</b>";
                         }
                     // Otherwise, if it's a directory, output a link to it.
                     } else if (is_dir($fullPath)) {
                         if ($output) {
                             echo "<li><a href=\"" . $docRootPath . "\">" . getDirName($docRootPath) . "</a>";
                         }
                     // Otherwise, output a link to the file.
                     } else {
                         if ($output) {
                             $currentName = getPageName($fullPath);
                             echo "<li><a href=\"" . $docRootPath . "\">" . $currentName . "</a>";
                         }
                     }
                     // If the current entry is the same as the place on the filesystem that the parent function is listing, 
                     // toggle the output. 
                     if ($docRootPath == $currentParentPath) {
                         $output = !$output;
                     }
                     if ($output) {
                         echo "</li>\n";
                     }
                 }
             }
             if ($output) {
                 echo "</ul>\n";
             }
         }
    }
    if ($buildPath != "/" && $output) {
        buildOuterNav($parentPath, $buildPath, FALSE, $level+1);
    }
}
 
echo "<h3>Navigation</h3>\n";
buildInnerNav($_SERVER["PHP_SELF"]);

?> 


Is there an easy way to fix this or should I just live with it?
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #2  
Old 20-Jan-2006, 20:41
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Changing PHP list link color


Hey Cody, do you have a "live" page showing this problem?

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #3  
Old 20-Jan-2006, 22:30
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: Changing PHP list link color


Assuming this is the markup:

HTML Code:
<div class="box"> <ul> <li><a href="/">Home</a></li> <li><a href="/dir-1/">Directory 1</a></li> <li><a href="/dir-1/subdir-1/">SubDirectory 1-1</a></li> <li>Web Page in Sub Directory 1-1</li> </ul> </div>

Update your stylesheet inserting something like this (assuming you want the links to be white):

CSS Code:
div.box li a:link	{ color:white; text-decoration:none; }
div.box li a:visited	{ color:silver; text-decoration:none; }
div.box li a:active	{ color:yellow; text-decoration:none; }
div.box li a:hover	{ color:white; text-decoration:underline; }
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #4  
Old 20-Jan-2006, 23:41
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,628
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Changing PHP list link color


Quote:
Originally Posted by cable_guy_67
Hey Cody, do you have a "live" page showing this problem?

Mark
Sorry, it's on an internal server that's not configured for "world access". I can show you screen shots, if you like.

I'll try what J suggested and see what happens.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #5  
Old 20-Jan-2006, 23:54
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,628
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Changing PHP list link color


Hey thanks, J. It's working now. I didn't realize I needed the li tag for each link; I only remember using a:hover etc. the last time I did color changes.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 21:30
linked list error message Krandygrl00 C++ Forum 4 22-Jun-2005 15:13
search linked list itsmecathys C++ Forum 20 18-Apr-2005 02:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:00.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.