• [1] Автоматический Генератор Карты Сайта
  • [2] Static list based folder tree


  • Автоматический Генератор Карты Сайта



    Автоматический Генератор Карты Сайта



     Автоматический Генератор Карты Сайта  [Автоматический Генератор Карты Сайта]  [Автоматический Генератор Карты Сайта]  [Автоматический Генератор Карты Сайта]

    Часто бывает так, что потихоньку развивая свой сайт, вебмастеру становится довольно непросто "уследить" за всеми страничками своего сайта. В результате - пользователь, зашедший на сайт, может долго искать нужную ему информацию или вообще не найти ее (хотя, фактически, она присутствует на сайте).


    Чтобы избежать подобных "казусов", как правило, на сайтах, имеющих несколько десятков страниц и больше, практикуется использование Карты сайта - специальной страницы сайта, на которой (обычно в виде иерархического дерева) представлены все странички сайта. Но, если сайт содержит более сотни страниц, то поддерживать вручную "в рабочем состоянии" Карту сайта довольно хлопотное дело.


    Бесплатный скрипт "Генератор карты сайта" предназначен для автоматического создания на сайте страницы "Карта сайта", на которой, в виде структурированного дерева, изображаются html-страницы, присутствующие на сайте.


    ВНИМАНИЕ! Не путать с SiteMap, которая предназначена для поисковых систем с целью индексации сайта!


    Скачайте и распакуйте архив на свой компьютер.


    Внесите свои настройки в файл makesitemap.php:

    • $workDir - указывается путь на диске к файлам сайта (по умолчанию индексируется весь сайт).
    • $exceptionFileList - названия файлов, которые не будут индексироваться и включаться в дерево карты сайта.
    • $exceptionDirList - названия папок, которые не будут индексироваться и включаться в дерево карты сайта.
    • $outFile - имя файла и путь куда будет записан результат генерации карты сайта.
    • $headerFile - имя файла и путь к нему, содержимое которого будет добавлено в результирующий файл перед деревом.
    • $footerFile - имя файла и путь к нему, содержимое которого будет добавлено в результирующий файл после дерева.


    По сути дела, надо только внести в $exceptionFileList, $exceptionDirList папки и файлы, которые не следует включать в итоговый файл карты сайта.


    Скопируйте файлы dtree.css, dtree.js и дирикторию img_sm в директорию где будет расположен результирующий файл sitemap.html.


    Скопируйте файл makesitemap.php в любое место.


    Чтобы не путаться, рекомендую загрузить все файлы и директорию img_sm в корень сайта.


    Обязательно установите на файл sitemap.html права доступа CHMOD 777.


    Изначально файл sitemap.html пустой, но после запуска скрипта он заполняется содержимым файлов $headerFile, $footerFile и собственно деревом каталогов.


    Для генерации карты сайта запустите на исполнение файл скрипта makesitemap.php (для этого наберите в строке бразуера путь к этому файлу, например: http://mysite/makesitemap.php).


    Результирующий файл карты сайта будет находиться в файле sitemap.html.


    При этом существуют следующие ограничения:

    • Индексируются только статические html-страницы.
    • ВНИМАНИЕ! Чтобы проиндексировалась какая-либо папка она обязательно должна содержать файл index.html.


    Кажется, все. Пользуйтесь! :)






    Static list based folder tree

    This is a list based folder tree. What you have to do is to create a <UL><LI> list. The script will then create the tree based on this list. The script uses cookies to remember state of nodes. It also includes functions for expanding/collapsing all nodes. You can add and delete nodes dynamically by right clicking on the nodes.

     Static list based folder tre  [Static list based folder tre]  [Static list based folder tre]  [Static list based folder tre]

    Configuration:

    Building a tree

    The menu is HTML based. You create the tree by building a nested <UL><LI> list.
    Example:

    <ul id="dhtmlgoodies_tree" class="dhtmlgoodies_tree">
    <li><a href="#">Main item</a>
    <ul>
    <li><a href="#">Sub menu item</a>
    <ul>
    <li><a href="#">Sub menu item</a>
    <ul>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    <li><a href="#">Sub menu item</a>
    <ul>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    <li><a href="#">Main item</a></li>
    <li><a href="#">Main item</a>
    <ul>
    <li><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    <li><a href="#">Main item</a>
    <ul>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Sub menu item</a></li>
    <li><a href="#">Sub menu item</a></li>
    </ul>
    </li>
    </ul>
    It's important that you give your tree(s) an ID. In the code above, you will see that I have given it the id
    dhtmlgoodies_treeYou should also notice that the tree need to be assigned to the CSS class
    dhtmlgoodies_treeExample:
    <ul id="dhtmlgoodies_tree" class="dhtmlgoodies_tree">

    Javascript configuration

    You have to create a reference to your tree(s) by use of Javascript. This is done by creating an array of the ID(s) of your trees. Example:
    var idOfFolderTrees = ['dhtmlgoodies_tree','dhtmlgoodies_tree2'];In the demo, I have two folder trees. The id of the first one is
    dhtmlgoodies_treewhile my second tree got the id
    dhtmlgoodies_tree2You will find the ID in the main <UL> tag. Example:
    <ul id="dhtmlgoodies_tree">You will find this array code at the top of the <SCRIPT type="text/javascript"> section.

    Icons

    The tree will use the icon defined in the Javascript variable folderImage as default. However, you may override it by declaring a class in your <LI>. example:
    <li class="dhtmlgoodies_sheet.gif">Here, the image "dhtmlgoodies_sheet.gif" will be used instead of the default icon.

    Javascript variables and functions

    You have these variables available at the top of your <SCRIPT> section:
    var idOfFolderTrees = ['dhtmlgoodies_tree','dhtmlgoodies_tree2']; var imageFolder = 'images/'; // Path to images
    var folderImage = 'dhtmlgoodies_folder.gif'; // Default folder image
    var plusImage = 'dhtmlgoodies_plus.gif'; // [+] icon
    var minusImage = 'dhtmlgoodies_minus.gif'; // [-] icon
    var useAjaxToLoadNodesDynamically = true;
    var ajaxRequestFile = 'writeNodes.php';
  • idOfFolderTrees = An array of the trees on your page
  • imageFolder = Path to your image folder
  • folderImage = Name of folder image file
  • plusImage = Name of file - plus icon
  • minusImage = Name of file - minus icon
  • useAjaxToLoadNodesDynamically = Use AJAX to load sub nodes dynamically?
  • ajaxRequestFile = Name of server side file, i.e. the file Ajax sends requests to
  • There's also two function you can call to expand or collapse all nodes. The "expandAll()" function expands all nodes, while the "collapseAll()" function collapses all nodes. Send the ID of the tree you want to collapse or expand as argument to these functions. Examples:
    expandAll('dhtmlgoodies_tree');
    collapseAll('dhtmlgoodies_tree2');

    If you use AJAX

    If you use Ajax to get nodes dynamically from the server, you can follow this recipe:
    Insert nodes in your tree like this:
    <li><a href="#">Europe</a>
    <ul>
    <li parentId="1"><a href="#">Loading...</a></li>
    </ul>
    </li>
    Notice that I have created an <LI> with a "parentId" parameter. The value of this parameter is sent to the file on your server(writeNodes.php). The file on the server will then output the nodes where parent ID = 1. This will be sent back to the script, and the script will replace the "loading.." <LI> with the new content from the server.

    The file "writeNodes.php" is only outputting plain HTML. Example:

    <li class="dhtmlgoodies_sheet.gif"><a href="#">Bergen</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Stavanger</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Trondheim</a></li>
    <li class="dhtmlgoodies_sheet.gif"><a href="#">Oslo</a></li>
    Look inside the writeNodes.php file for more information. I'm not using a database in this demo. If you use a database, the writeNodes.php file could typically look like this:

    <?php
    if(isset($_GET['parentId'])){

    $res = mysql_query("select * from category where parentId='".$_GET['parentId']."'");
    while($inf = mysql_fetch_array($res)){
    echo "<li><a href=\"#\">".$inf["categoryName"]."</a>";

    $resSub = mysql_query("select ID from category where parentId='".$inf["ID"]."'");
    if($infSub = mysql_fetch_array($resSub)){
    echo "<ul><li parentId=\"".$inf["ID"]."\"><a href=\"#\">Loading...</a></li></ul>";
    }

    echo "</li>";

    }
    ?>

    Cookies

    Cookies are used to remember state of the nodes. This means that when you revisit the page, the script will expand the nodes that were expanded when you last time left the page.

    Add/Delete nodes dynamically

    New nodes can be added and deleted dynamically from a context menu. You can disable this feature by setting the JS variable contextMenuActive to false at the top of folder-tree-static.js.

    When a new node is added, a function called saveNewNode() is called. You will find this function inside folder-tree-static.js. You need to enable the ajax part of this function(it's in comments right now). You also need to add support on your server for saving new nodes. When a node is created a request is sent to the file defined in the variable ajaxRequestFile. Variables sent to this file are:

  • newNode = Title of new node
  • parentID = ID of parent node
  • All you have to do is to have an insert query which inserts this new node in your database.

    The same also applies to what's happening when you delete a node. You have to enable the ajax part of the function deleteNodeOnServer. This will send a request to the server where the node to delete is defined in the variable deleteNodeId

    Update log

    June, 11th, 2006 - Added support for adding and deleting nodes dynamically

    Created/Updated: 25.05.2018

    stop war in Ukraine

    ukrTrident

    stand with Ukraine