Incorporate htdocs project listing into XAMPP’s start page

Imagine… you work on a few local web projects and every time you want to launch one of them in a web browser, you need to type their address in an address bar. Having all of web projects as a list of links in one page is a real time-saver.

 

Create link to directory listing

  • go to C:\xampp\htdocs\xampp\navilinks and create file fen_projects.htdocs-usb
  • paste this into the file and save changes
    <a target="content" onclick="h(this);" href="/htdocs_listing.php">List of projects</a>
  • go to C:\xampp\htdocs\xampp\navi.php and find the following piece of code
    <?php 
    rendernavi("php");
    ?>
    
    <?php 
    rendernavi("perl");
    ?> 
    
    <?php 
    rendernavi("j2ee");
    ?> 
    
    <?php 
    rendernavi("tools");
    ?>

    and add this code at the bottom

    <?php 
    rendernavi("htdocs");
    ?>

    Function ‘rendernavi’ will take the newly created file (with .htdocs* extension) and convert it into a menu. The newly created piece of menu has now “htdocs” header (provided in the brackets) and a list of links (there is only one in this tutorial – “List of projects”) stored inside fen_projects.htdocs-usb file.

 

Create directory listing page

  • go to C:\xampp\htdocs and create file htdocs_listing.php
  • paste the code below
    <!DOCTYPE html>
    <html>
    <head>
    <link href="xampp/xampp.css" rel="stylesheet" type="text/css">
    <title>list</title>
    <base target="_blank"/>
    <style>
    .list ol li { margin-bottom:5px; font-size:125%;}
    .list ol li a { font-size:125%; text-decoration:none; }
    .list ol li a:hover { text-decoration:underline; }
    </style>
    </head>
    <body>
    
    <?php
    $htdocs = opendir(".");
    $list= '';
    
    while ($project = readdir($htdocs)) 
    {
    if (is_dir($project) && ($project != "..") && ($project != ".")) 
    $list .= '<li><a href="'.$project.'">'.$project.'</a></li>';
    }
    
    closedir($htdocs);
    
    if (!isset($list))
    $list= "No list";
    ?>
    
    <div>
    <ol>
    <?php echo $list ?>
    </ol>
    </div>
    
    </body>
    </html>

 

Test

  • go to C:\xampp\htdocs and create ‘Test’ folder
  • copy file index.html from C:\xampp\htdocs and paste it into the newly created ‘Test’ folder
  • make a few copies of the folder inside htdocs
  • launch xampp control panel and start Apache Server
  • open a web browser and go to localhost
  • at the bottom of xampp’s menu appears a newly created htdocs section – click List of projects link
  • Click test link

xampp_htdocs_listing_01xampp_htdocs_listing_02 xampp_htdocs_listing_03

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>