...

View Full Version : Resolved Menu problem.



martynball
02-07-2010, 01:39 PM
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/stokeGTA/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 $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.

abduraooft
02-07-2010, 01:58 PM
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.php?p=784167&postcount=9 for details.

martynball
02-07-2010, 02:18 PM
Tryed that:



<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/stokeGTA/acp/stokeGTA/mainPage.php?type=vehicles

abduraooft
02-07-2010, 02:22 PM
Tryed that:



<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/stokeGTA/acp/stokeGTA/mainPage.php?type=vehicles

Try

<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>

martynball
02-07-2010, 02:24 PM
Cool, that works. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum