topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 8:09 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: propagate a style.css and index.php to work in all subdirectories in a webfolder  (Read 5969 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Thanks to those who offered answers on the php website for hosting files.   

Working from all your suggestions i was finally able to get exactly what i wanted.   Unfortunately, I have run into a problem with the CSS for the folder that contains the document files. 
The hosting file is an Apache Website that does exactly as needed.  I can add a folder to it named 'documents' that will display the documents in it in a perfect format exactly as asked.  The problem is that for it to work,  it requires a specific 'index.php and 'style.css' that are not used elsewhere.  To get the documents to display in all levels of each subfolder,  I have to put th0ose two files in each of the directory levels of every folder. 
Sublevels without those two files use the default Apache directory listing CSS which does not look very good.

Is there a place or file I can use to set the 'documents' folder to always display using the special index.php and style.css on every subdirectory in that folder?
Thanks for advice

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
I'm not an expert on Apache, but if al else fails, you could create logical links to the 2 files in each subfolder, avoiding duplicate files, and keeping a single point of maintenance.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Any chance you can share those index.php and style.css files to see if a fix might actually be possible in the index.php file?

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
ATH:  i have attached the entire code here.  Only the style.css and Index.php are giving me problems.
i was able to add the single java code to the website JS folder andit works fine from there
And when you look at then, you will see inside them both it shows he the path and was what I assumed was the problem.  It shows their location to be "./name"
as in ./.style.css  and ./.index.php etc

it is a very concise and simple directory display snippet for an apache website.  Now if only it would work on folders that have multiple subfolders etc.  Instead the site drops back to using the apache directory listing default after level 1

Sorry not sure what i did wrong the first time  but the attachment failed.  the other post has complete code in DDC.zip
« Last Edit: October 31, 2019, 06:04 PM by questorfla »

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member


DUH  I think i don't wait long enough.  :(

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
About Apache configuration:
AFAICS, you should start reading (and some experimenting) on this Apache wiki page about DirectoryListings and how to configure that. I have no LAMP/WAMP installation available, so am unable to provide more detailed pointers, sorry.

About the .style.css file needing to be copied into each directory:
This is caused by this line in .index.php:
<link rel="stylesheet" href="./.style.css">
It points to that file in the current directory ( ./ in front of the filename is a relative location).

By placing the .style.css file into a specific directory like directorystyle in the root of your website, and changing the above line into:
<link rel="stylesheet" href="/directorystyle/.style.css">
you are addressing the file at it's absolute location, and has to be stored only once at the server.
Renaming the file and moving it to the default styles directory is also an option, ofcourse.

The period as the first character of the filename makes the file invisible on *nix OS's, and it can be omitted if the file is moved out of the directories that are visible to the enduser. The name used in .index.php has to be adjusted accordingly, as is to be expected ;)
The same goes for the .index.php file, after you have moved it out of the visible directories using the first pointer in this post.

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Thanks.  Your Instructions might get me there.  Eventually.  I had already tried changing the index.php for something similar and even with your exact wording it only works if i include a copy of both index.php AND a copy of styles.css in every subdirectory of every folders in documents directory.   
I am sure you are correct and it does have something to do with the relational path but for some reason on this setup I can't seem to get anything to work other than as it was
 
Many Thanks for your help.   At least I know now that I was looking in the correct direction.  One of the other members also sent me to a file called directory lister and for some reason THAT one Does work properly and even has the added pointers for forward and back.  But:  It is hard to read with fonts too small and colors light and it doesn't have an easy to work with styles.css like this one to make changes.   I wish i could merge the best of both. 

Maybe I need to try to merge the path statements from the new index.php such that it is stated in the first instance of index.php  on the website?  Rather hqan the following one it finds in the documents folder?    Or maybe it would be easier to change the Look of the directory lister snippet instead? https://github.com/topics/directory-lister Always some kind of decision to make.  :(