quagmire02 All American 44225 Posts user info edit post |
stupid question i will more than likely get ridiculed for, but such is the nature of tdub
i know html/xml pretty well...css makes sense, i don't have formatting trouble and my site is overly simple...however, i do NOT know the more powerful programming languages of things lik PHP, so i'm at a loss as to how to do this:
let's say my site has 6 pages in 3 categories set up with the following file structure (bracket indicates a folder, dash indicates a file):
ROOT [content] [contact] -about.html -directions.html [faqs] -ask.html -answer.html [products] -overview.html -details.html -contact.html -faqs.html -products.html [css] -index.css -site.css [images] -logo.jpg -image1.jpg -index.html
does that file structure make sense? anywho, you start out on a gateway page (index.html)...you select from the main menu one of the three options (the three .html files in the "content" folder)...once you get to that page, you have two more sub-menu options in addition to the 3 main menu options (the files within the corresponding folder comprise the sub-menu - for example, "contact.html" references the two files in the "contact" folder)...get it?
i'm using includes to put in "logo.jpg" and the main menu (with the options being the three .html files inside the "content" folder)...these components (logo and main menu) are included on every single page no matter where it is on the site...makes sense, right?
so here's the problem - these includes have to have different file paths depending on what level (how deep) the .html file is at ("contact.html" and "about.html" can't have the same link to "index.html" because it's relative to location)...right? so at this point, i'm barely saving any coding time by using includes because i have to have a different one for each level
my question is this - is there a way to reference an external file (the same way you include a .txt file containing the html coding for the main menu) that will reference the external file's location instead of the location of the .html document that called it? CSS works like this...if i have all of my stylesheets in the "css" folder, then i make any links (say, background images) relative to the .css file's location, not the .html file that uses it
does any of this make sense? yes, i realize that a more powerful/functional code can do this...but i don't KNOW other code, and as this isn't my job (the example is just an example...i'm working on my own personal site), i don't really want to take the time to learn (even basically) another language
any help will be much appreciated 6/20/2006 2:24:02 PM |
darkone (\/) (;,,,;) (\/) 11610 Posts user info edit post |
Try using absolute links instead of relative links.
e.g. Use - http://www.yoursite.com/faqs/pageyouwant.html and not ../faqs/pageyouwant.html 6/20/2006 2:27:35 PM |
agentlion All American 13936 Posts user info edit post |
use dreamweaver and DW templates to take care of the relative links for you 6/20/2006 3:29:11 PM |
quagmire02 All American 44225 Posts user info edit post |
^^ i don't like to do that because i can't test anything off-line
^ i don't own dreamweaver...i really like hard coding (i know dreamweaver gives you design and code views)
i appreciate the suggestions...i was just curious as to whether or not there were any code possibilities that i wasn't aware of
EDIT: the file structure diagram didn't come out like i wanted...so i may not have explained what i meant clearly enough
[Edited on June 20, 2006 at 4:20 PM. Reason : structure] 6/20/2006 4:17:52 PM |
Ernie All American 45943 Posts user info edit post |
learn php
[Edited on June 20, 2006 at 5:10 PM. Reason : http://us2.php.net/include/] 6/20/2006 5:09:50 PM |
Noen All American 31346 Posts user info edit post |
use absolute links relative to the web root
aka
/faqs/pageyouwant.html
just make sure your php base path settings are mapped to the web root directory. Otherwise set the open base path and then call it.
This will work on your local server and remotely. 6/20/2006 5:34:41 PM |
quagmire02 All American 44225 Posts user info edit post |
okay...so if i put this:
<? include("main_nav.php") ?>
on my page, once i upload it will simply insert the code contained in the "main_nav.php" file? won't i run into the same problem as using
<!-- #include file="../includes/main_nav.txt" -->
? also, using the php code above, can i use a relative path like the .txt one above?
EDIT: i admit that i understood very little of ^...can you give me an example of how it would be coded?
[Edited on June 20, 2006 at 5:40 PM. Reason : .] 6/20/2006 5:39:03 PM |
Prospero All American 11662 Posts user info edit post |
Quote : | "This will work on your local server & remotely" |
just to clarify this will work if you have a locally install of IIS on your computer w/ php installed. this is unlike html/css because those will work even if you don't have IIS installed.6/20/2006 6:08:59 PM |
marilynlov7 All American 650 Posts user info edit post |
^^
You don't need the () so it should be: <? include 'main_nav.php' ?>
That will pull the file, if its in the current working directory. So yes, in essense, you have the same problem as before. But, as stated in the thread, if you make it from the web root, add something to your tree like:
[php]
and then put main_nav.php in there, then you could do something like:
<? include '/ROOT/php/main_nav/php' ?> where ROOT is the name of the main directory ofthe page, so say you called the direcotry that you have labeled ROOT MyPage just replace ROOT with MyPage, whatever is in the directory tree.
If you do that, then no matter what directory the page you are accessing is in, it will know where to look for the main_nav.php file. 6/21/2006 1:44:07 AM |
quagmire02 All American 44225 Posts user info edit post |
^ i might be misunderstanding your post...it seems like your solution is pretty much what i have now, simply using an include file...my problem is that it inserts the code into the calling file (which, i know, is what it's supposed to do)...however, that means any image links that are in the CALLED file have to be written in relation to file CALLING the include
that doesn't really help me as it means that i can't use the same snippet of code for files at different levels because the links won't be the same
let me try to explain what i'm looking for (which people may have understood, but i haven't really found a solution yet)...when an external CSS file is included on a page, it doesn't matter where the calling page is located...links within the CSS file are relative to the file itself, not the calling page (which is why you can use a single CSS file for an entire website)...i want the same thing, but i want to use it for calling snippets of code that will be the same on ALL pages (the main menu, for example)
i COULD use a base href, or use absolute links, but like i said, it doesn't allow me to work offline...i also would prefer not to use dreamweaver (or similar) because i'd rather rely on code options
i do, however, appreciate everyone's input 6/21/2006 1:04:48 PM |
quagmire02 All American 44225 Posts user info edit post |
bttt 6/22/2006 8:48:04 AM |
dFshadow All American 9507 Posts user info edit post |
too many words
skype me and explain it and i might think about it hahaha
[Edited on June 22, 2006 at 11:27 AM. Reason : .] 6/22/2006 11:26:21 AM |
quagmire02 All American 44225 Posts user info edit post |
6/22/2006 2:40:24 PM |
Noen All American 31346 Posts user info edit post |
dude, we are being EXTREMELY basic with you here.
if you dont understand what we are telling you it's because you don't understand basic principles, not because we aren't giving you what you want.
You need to learn PHP, and programming in general. Go get a book. 6/22/2006 3:09:10 PM |
quagmire02 All American 44225 Posts user info edit post |
well, you really aren't answering my question (not that you have any obligation to), which is why i keep repeating it...the question is:
Quote : | "is there a way to reference an external file (the same way you include a .txt file containing the html coding for the main menu) that will reference the external file's location instead of the location of the .html document that called it?" |
the majority of the responses are geared toward what i already know and am doing...except for yours, Noen...it seems like you might understand what i'm asking (and have a possible solution), but you didn't expound upon it (i would be grateful if you would)...i'm betting i do NOT need to know all about PHP in order to do this and i don't see how buying a book is going to make a difference
if anyone can refer me to an online resource regarding this issue (i don't even know what the search for, otherwise i'd do it myself), i would appreciate it...better yet, if anyone has the physical files that already do this, i'm pretty sure i can figure it out after seeing an actual coded example6/22/2006 3:20:21 PM |
Noen All American 31346 Posts user info edit post |
The absolute direct, exact and concise answer to your question is:
Quote : | "use absolute links relative to the web root
aka
/faqs/pageyouwant.html
just make sure your php base path settings are mapped to the web root directory. Otherwise set the open base path and then call it.
This will work on your local server and remotely.
" |
EX:
You may have to adjust the path to reflect whatever your server's php.ini web root folder is, which you can find by doing a phpinfo(); call.
Seriously. If you don't understand why this is doing exactly what you want, you NEED TO LEARN THE BASICS.6/22/2006 3:54:47 PM |
Ernie All American 45943 Posts user info edit post |
seriously you can just search for an html tutorial
this is pretty basic stuff and should be covered in detail in any tutorial 6/22/2006 4:14:09 PM |
quagmire02 All American 44225 Posts user info edit post |
^^ that little bit of additional explanation DID help and i found a tutorial using some keywords you provided...thank you (no sarcasm)
^ html isn't the issue...php, which is MORE difficult, is the issue
thanks for suggestions everyone 6/22/2006 8:09:58 PM |
Ernie All American 45943 Posts user info edit post |
seriously you can just search for an php tutorial
this is pretty basic stuff and should be covered in detail in any tutorial 6/22/2006 8:38:44 PM |
marilynlov7 All American 650 Posts user info edit post |
http://www.w3schools.com/
[Edited on June 22, 2006 at 9:24 PM. Reason : http://www.w3schools.com/] 6/22/2006 9:24:06 PM |
quagmire02 All American 44225 Posts user info edit post |
that's a good site (been there long time ago) 6/22/2006 9:25:28 PM |
Raige All American 4386 Posts user info edit post |
htmlcodetutorial.com is one of the best sites out there for basic questions. w3schools covers a lot more but doesn't have a learning path associated with it. 6/22/2006 9:46:41 PM |
lafta All American 14880 Posts user info edit post |
Quote : | "[faqs] -ask.html -answer.html " |
i thought the rule on [faq]'s were dont ask, dont tell6/22/2006 9:49:46 PM |