Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Menu problem.

  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post

    Menu problem.

    I hvae just made this script, the idea is that "../" is printed in the url so that the links will displayed like so:
    <a href="../../ucp.php">UCP</a>

    Without the "../" they display like this:
    http://martynleeball.x10hosting.com/...TA/acp/ucp.php

    Although the page is actually in the stokeGTA/ folder and not acp/

    Another example of what the script should do:
    If the current location of the script is like so:
    root/folder1/folder2/folder2/page.php
    The links which will be linking to page in "root" will be like so:
    <a href="../../../index.php">Home</a>

    PHP Code:
    <?php $root $_SERVER['PHP_SELF'];$root explode("/"$root); $root count($root); $i 2;  ?>
    <div class="navlist" style="margin-top:1em;">
    <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>index.php">Home</a></span>
    <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>ucp.php">UCP</a></span>
    <?php if($_SESSION['permissions'] == "e") { ?> <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>newuser.php">Add User</a></span> <?php ?> 
    <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>mainPage.php?type=locations">Locations</a></span>
    <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>mainPage.php?type=vehicles">Vehicles</a></span>
    <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>mainPage.php?type=weapons">Weapons</a></span>
    <?php if($_SESSION['permissions'] == "e") { ?> <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>settings.php">Settings</a></span> <?php ?> 
    <?php if($_SESSION['permissions'] == "e") { ?> <span class="tabs"><a href="<?php while ($root $i) { echo "../"$i++;  } ?>acp/admin.php">ACP</a></span> <?php ?> 
    <span class="tabs"><?php while ($root $i) { echo "../"$i++;  } ?></span>
    </div>
    I am sure there is an easier way to do this.
    Last edited by martynball; 02-07-2010 at 02:26 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    I am sure there is an easier way to do this.
    I prefer the use of absolute paths beginning with /, to refer all elements from client side. It'll reduce all complexities when including html files containing anchors in different places.

    See http://www.codingforums.com/showpost...67&postcount=9 for details.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Tryed that:

    Code:
    <span class="tabs"><a href="stokeGTA/mainPage.php?type=locations">Locations</a></span>
    <span class="tabs"><a href="stokeGTA/mainPage.php?type=vehicles">Vehicles</a></span>
    The link is now: http://martynleeball.x10hosting.com/...?type=vehicles
    Last edited by martynball; 02-07-2010 at 02:21 PM.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Quote Originally Posted by martynball View Post
    Tryed that:

    Code:
    <span class="tabs"><a href="stokeGTA/mainPage.php?type=locations">Locations</a></span>
    <span class="tabs"><a href="stokeGTA/mainPage.php?type=vehicles">Vehicles</a></span>
    The link is now: http://martynleeball.x10hosting.com/...?type=vehicles
    Try
    Code:
    <span class="tabs"><a href="/stokeGTA/mainPage.php?type=locations">Locations</a></span>
    <span class="tabs"><a href="/stokeGTA/mainPage.php?type=vehicles">Vehicles</a></span>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    martynball (02-07-2010)

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Cool, that works. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •