moldboy
Sep 23 2005, 04:47 AM
| | I am looking for a way to make a dynamic menu using php and include, basicly I want to make a file that contains html formating source and links and include it somewhere in all my pages, the problem is that links are taken literaly and refered to as to where the html is running from. So is there a way I can make a file and include it in my pages, then it will determin where the page is running from, and generate the links with an approperate amount of ../../'s so if my index is at root, but every section has it's own folder, I want to be able to include this file in all the pages, and have the path to the pages changed.
I don't expect anyone to spoon feed me the code, but any suggestions would be apprecieated. |
Reply
Tyssen
Sep 23 2005, 05:46 AM
Is this what you're after: CODE $docRoot = $_SERVER['DOCUMENT_ROOT']; <?php include ("$docRoot./nameofyourfolder/nameofyourinclude.htm"); ?>
Reply
Spectre
Sep 23 2005, 03:59 PM
In my opinion, it is usually a better idea to specify the value of hypertext references (the 'href' element of an 'a' HTML tag) relative to the root directory of your site rather than relative to the current directory - such as, for example, in '/folder/subfolder/index.html', use '<a href="/folder2/page.html">' rather than '<a href="../../folder2/page.html">'. It may sometimes mean adding a bit more text, but it also means it is easier for clients to locate files. Anyway, if you are generating your menu dynamically, it would probably be a better idea simply to 'echo()' (or otherwise send as output) the HTML code from the PHP script being used. I don't know why you would need to re-create the menu every time it is viewed, but you obviously have your reasons.
Reply
moldboy
Sep 23 2005, 11:59 PM
QUOTE I don't know why you would need to re-create the menu every time it is viewed, but you obviously have your reasons. Correct me if I'm wronf but a <a> link will go relative to a page, so as in the site I'm about to outline: /index.html /fol1/index.html /fol1/index2.html /fol2/home.html /fol2/home2.html If I were on /index.html and clicked a link that pointed to <a href="fol1/index.html"> that could bork, but if I were on that page and clicked a link to <a href="fol2/home.html"> the client would look in (root)/fol1/fol2/home.html because it would be looking up from the current page, if if I were to make a file and using include add it to all my pages then on every page it would link to the files as fol#/filename.html whether or not that file actualy exists, so I would make my navigation so it worked on the root index.html page, yet when that same navigation would be included in any other page not only would the home link not work, but none of the other links would either, that is because the link <a href="index.htm"> from /fol2/home2.html would report a 404 because there is no file at /fol2/index.html QUOTE <a href="/folder2/page.html">' rather than '<a href="../../folder2/page.html"> That being said please tell what you mean by the above code, maybe I missed something.
Reply
Spectre
Sep 24 2005, 06:52 AM
Uh, yes... I think you're missing what I said. A hypertext reference is treated by the client as relative to the current directory (and directories are obviously delimited by a '/'). Which is why I said that I think you should always specify a link's path relative to the root directory of the site, NOT relative to whatever directory you are currently in. So if you were current viewing '/fo1/index.html' and wanted to get to '/fo2/index.html', then in my opinion, it would be better to specify a link to '/fo2/index.html' rather than '../fo2/index.html'. Or if you were currently viewing '/fo1/fo2/fo3/fo4/file.html' and wanted to get to '/fo1/index.html', then you should use '/fo1/index.html' as opposed to '../../../index.html'. Anyway, you're obviously free to create your web pages however you wish.
Reply
Tyssen
Sep 24 2005, 08:14 AM
What Spectre is talking about is absolute (/) and relative (../) URLs. The only time you should really use relative URLs is when the links are in the same folder (or in a sub-folder within that folder) as the page accessing them. Whenever you link to anything in a directory above the one you're in, you're better off using absolute URLs which start from the / which is the root of your directory and then work down.
Reply
moldboy
Sep 24 2005, 06:41 PM
Sorry about all the trouble I've been causing, didn't realise you could do that  ! Thanks for your help. Anyway Mods feel free to close this thread. Thanks again
Reply
alexia
Oct 12 2005, 01:15 AM
i think its better convert html file in to JS file and then use script like : <script src=your address></script> include its very slow but this script load pages and element fast
Reply
Tyssen
Oct 12 2005, 02:06 AM
QUOTE(alexia @ Oct 12 2005, 11:15 AM) i think its better convert html file in to JS file and then use script like : <script src=your address></script> include its very slow but this script load pages and element fast  What a load of rubbish.
Reply
Similar Topics
Keywords : dynamic, included, menus, path, specification
- Getting An Array Value Of A Dynamic Variable
(9)
Trap17 Board Status Dynamic Image
(13) I was really board a few days ago and decided to make a trap17 board status image for my sig
/tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> That is the
current beta. I'm still working on it so that it might display the most recent post or
somthing, i'm not sure. After I finish it ill give out the source code but if you want one
right now you can pm me and ill set one up to get the info on your account ^.^ So I was wondering
how you members liked it? You'll probably think that its a waist of time, but alas as I sai....
Can I Make Dynamic Menu In Php
is it posible to make dynamic menu in php without javascript (7) As there are many java script by which we can have event based interaction like,message on mouse
over etc,that we can create dynamic menu in javascripts to make navigation bar ,but is it possible
in php to have this acomplished without javascripts,i am new to php,is it possible?. Thanks....
More Dynamic ?id=browsing With Php (associative Array)
Just create array and watch php code do the rest (1) The thing that has been bugging me for a while was that switch statement that we use to create ID
browsing (some use If-Ifelse but results are the same for both). I wanted to figure out a way to use
more dynamic switch statement so that i only need to update my links array in order to create links
for template. With use of foreach, array_keys, and in_array functions finally i managed to do so.
Also i'm planing on changing foreach with array_walk but i'll do that later. Now for the
code.. First we create an associative array something like this CODE $gl....
Dynamic Php Pages
Nice tutorial (5) This is a really good tutorial on making php pages that normally appear as
www.domainname.com/links.php appear as www.domainname.com/index.php?page=links
http://nuwen.com/tutorials/php-dynamic-pages ....
Dynamic Image / Signature Generator
a simple code to change text on an image (12) In search of dynamically changing quote, saying or all other types of text on an image I came across
a code that I have modified to fit my initial usage. This procedure requires two files and short
knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
CODE <?php header("Content-type: image/png"); ....
Dynamic Drop Down List <select>
(3) Hi, What I am trying to achieve is when you have a form drop down menu, it displays all the
categories from the directory, with all the indentations. Something like when you submit your site
to a directory. Now I've got it almost working, but I can figure out how to indent it. The code
below, I've used a spacer gif, but obviously that won't work! I've had a go at
this, as you can see, but that does do the indentations, unless I'm doing something wrong here.
Any help appreciated - thanks. PHP Code: CODE function maketree($root....
Php Menus Without Javascript
Has PHP possibility to do it without JS (7) I have many PHP Books, PHP Bible among others, but no clear description how to build menus (dynamic)
Javascript like. Is PHP enough strong to do this? I also have Javascript Bible, many possibilities
are usable within PHP pages. Anybody has experience in creating dynamic menus in PHP? ....
Php Dynamic News Updating Using Mysql
changing a sites news using MySQL and PHP (3) Hey everyone. It appears to me that everyone really know what they are doing in this forum and im a
pretty new to this PHP and MySQL combo. I know some PHP but not MySQL....I am trying to make a new
website but i want to be able to go to a certain update page and change the news on the main index.
For example: - The main page show news updates of the last 10 post. - I go to the update page
and then fill in the form and it will add this post to the top of the list and still only print the
top 10. I have no clue how to do this with MySQL. At the moment i am doing it u....
Calling A Variable From A Dynamic List In A Sql Statement
(2) I would be greatful if anyone could help me out, I have been stuck on this for a while. The problem
is that I have a drop down menu which I get the contents of from a database. Then when I press the
get details button I want to use the value selected in my drop down menu and pass it into an SQL
statement to recieve all te relevent info. Everything works if I specify a known variable, but the
problem seems to be passing a variable in which is part of the array. Below is the code for the drop
down menu and the Sql statement i'm trying to execute. drop down menu: ....
Looking for dynamic, included, menus, path, specification
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for dynamic, included, menus, path, specification
*MORE FROM TRAP17.COM*
|
advertisement
|
|