Solved

Specific formatting for header

Posted on 2014-02-21
20
127 Views
Last Modified: 2014-05-01
Hello, we have some code that reads a director and its sub-directories for any and all files. Currently in our css we have it where for every directory be place a background on it. I would like to change the code slightly so that only top level directories will have the background but all sub-directories will not. Here is the code to go through the folders:

if ($files != null) {
    chdir ($rootDir);
    //sort files first, then folders alphabetically
    usort ($files, create_function ('$a,$b', '
      return  is_dir ($a)
        ? (is_dir ($b) ? strnatcasecmp ($a, $b) : 1)
        : (is_dir ($b) ? -1 : strnatcasecmp ($a, $b));
    '));
    
    echo '<ul>';
    foreach($files as $file) {
      chdir ($rootDir);
      if (is_dir("$file")){
        echo '<li class="folder"><div class="heading">'.$file.'</div>';
        getDirectory("$path/$file",($level+1));
        echo '</li>';
      } else {
        $info = pathinfo($file);
        $fileNameOnly = basename($file,'.'.$info['extension']);
        $file = str_replace(array('&',','), array('%26','%2C'), $file);
        $fileNameOnly2 = str_replace(array('_','&'), array(' ','&amp;'), $fileNameOnly);
        if (strpos($path, '/secure/') == FALSE)
          echo '<li class="file"><a href="/images/'.$path.'/'.$file.'" target="_blank">'.$fileNameOnly2.'</a></li>';
        else
          echo '<li class="file"><a href="/index.php?option=com_imagedownload&file=/images/'.$path.'/'.$file.'" target="_blank">'.$fileNameOnly2.'</a></li>';
      }
    }
    echo '</ul>';
  } else {
    echo '<ul><li class="noDownloads">No Downloads Available.</li></ul>';
  }
}

Open in new window


_______________________________________________________________________________

Below is the .css class that is being used:

#download-list  .heading{
	background-color: #c6b786;
}

#download-list li.folder{
	font-weight: bold;
	color: white;
}

Open in new window


Any help on this would be great
0
Comment
Question by:DancingFighterG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
20 Comments
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39878179
Try changing your style to

#download-list > li.folder{
	font-weight: bold;
	color: white;
}

Open in new window

0
 

Author Comment

by:DancingFighterG
ID: 39878230
JulianH,

This is the same code I posted. Did you mean to post something else?
0
 

Author Comment

by:DancingFighterG
ID: 39878241
Here is a screenshot of what the code does now. I simply want to take away the background from the sub-folders it finds

Screen formatting
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39878245
Not it is not. Note the first level selector '>'

#download-list > li.folder{ /* Note the extra '>' */
#download-list li.folder{
0
 

Author Comment

by:DancingFighterG
ID: 39878260
Oh I just noticed that. What does adding the ">" do?
0
 

Author Comment

by:DancingFighterG
ID: 39878268
The only thing it did is took away the white color on the header text
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39878836
The > means take only the immediate child so

<ul>
   <li>
      <ul>
         <li>
         </li>
      </ul>
   <li>

with your code would style li's at all levels

where as putting the > in would mean only the top level

Can you post your full code or the generated HTML output.
0
 

Author Comment

by:DancingFighterG
ID: 39879453
I've attached the css file and the default.php file that we are using.
template.css
default.php
0
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39880687
This should do the trick
#download-list ul ul .heading {
	background: none !important;
}

Open in new window

0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39880837
In fact this is probably more correct
#download-list > ul > li > div.heading {
  background-color: #C6B786;
}

Open in new window

Replace code in previous post with this.
0
 

Author Comment

by:DancingFighterG
ID: 39883483
It worked. Is there anyway to indent the sub items. This is what it looks like right now:
screen2.png
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39883711
That should be handled by lines 292 onwards of your stylesheet.

On my side I am seeing this using the stylesheet you posted. The changes recommended above should not have affected the indenting of your code.

Screenshot
0
 

Author Comment

by:DancingFighterG
ID: 39884036
I didnt see the new code that you posted until now. Just applied it but getting the same result. I've attached the file
template.css
0
 

Author Comment

by:DancingFighterG
ID: 39884063
Here is a screenshot of what I have right now:

screen3
0
 

Author Comment

by:DancingFighterG
ID: 39884067
Here is the php file that is doing to pull of the file system.
default.php
0
 

Author Comment

by:DancingFighterG
ID: 39886279
Hey Julian, I went back to this:

#download-list ul ul .heading {
      background: none !important;
}

Because it does not but the background on all the folders but I still want to indent. This is what it looks like now
screen3.png
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39887985
Ok but the indenting is done by margins - not by changing the background.

Somewhere in your styles you have removed the margin on your <ul> elements.

What browser are you using?
0
 

Author Closing Comment

by:DancingFighterG
ID: 40035011
Great Work!!
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 40035298
You are welcome - thanks for the points
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question