View Full Version : What is the best way to get my menu on every page
Benedizione
03-16-2007, 02:26 AM
I have had a terrible time getting logged into this program to post a question! Managed to figure out some css coding eventually of which I had never used before. I replaced a css coded menu where I used to have "frames." Now, I am wondering if there is a way to make my menu appear on all my pages without copying and pasting the css code on every page? That is, other than using "frames" again. I would like to avoid "frames" if possible.
The website I am trying to work on is here........ http://elvispics.tripod.com/
Andrea
Cball
03-16-2007, 01:07 PM
Here is a link to CSS Frames
http://www.dynamicdrive.com/style/layouts/category/C11/
But I just copied and pasted all the code on every page for my site.
ddadmin
03-16-2007, 11:02 PM
Actually, what you want is to use something like SSI (server side includes). When you see pages with a .shtml extension, that's SSI at work. Check out the following tutorial: http://www.javascriptkit.com/howto/ssi2.shtml
djr33
03-16-2007, 11:38 PM
PHP and other server side programming languages can give you more control over the process if need be. For the basics, that should work, though.
boxxertrumps
03-16-2007, 11:46 PM
Here is the php script i use for my menus...
function menu($main) {
$full = file_get_contents("http://localhost/includes/menu.txt");
$ready = explode("\r\n", $full);
$count = "0";
while (($count >= "0") && ($count <= count($ready)-2)) {
$one = explode("|", $ready[$count]);
if($main == TRUE) {
echo "<div class=\"item\"><a href=\"". $one['0'] ."\">". $one['1'] ."</a></div>\r\n<div class=\"spacer\"></div>";
} else {
echo "<br /><a href=\"". $one['0'] ."\">". $one['1'] ."</a>\r\n";
};
$count++;
};
};
Then in menu.txt i have
http://domain.com/url|Item name
htp://domain.com/?page|next item name
etc...
djr33
03-16-2007, 11:52 PM
But you'd need to include that in each.
Or you could do another layer of PHP includes, so that you use one main php page included on each page, which has already parsed the text file.
boxxertrumps
03-17-2007, 12:16 AM
Thats actually what i did, i have several includes on my main index.php file.
but the reason i needed it as a function was to display the same links differently. (Here (http://boxxer.mooo.com/) and Here (http://boxxer.mooo.com/games/))
Benedizione
03-17-2007, 02:10 AM
For instance, if I wanted to use this css frame layout http://www.dynamicdrive.com/style/layouts/item/css-top-frame-layout/ would I create a filename like "menu.txt" (or what?) and put in this code and fill in the appropriate fields???
Does this work similiar to using simple ordinary frames? I did not see any information on the page to define how to use the code.
Andrea
ddadmin
03-17-2007, 10:56 AM
Benedizione:
You wouldn't be using CSS frames at all if what you're trying to do is include a file into multiple pages (so changing that file is reflected on all pages that carry it). CSS Frames is just a type of layout whereby a certain section of the page doesn't scroll with the rest of the content. It has nothing to do with what you're trying to accomplish here, which needs to be done via a server side technology, such as SSI or PHP. The key is what the page type of your site is- .shtml, .php, or some other server side enabled pages.
Benedizione
03-18-2007, 02:54 AM
Ok, so I can use a "PHP" coding and create a page called "menu.txt" and put this code on that page:
Then in menu.txt i have
http://domain.com/url|Item name
htp://domain.com/?page|next item name
etc...
Then where do I place the other long coding you posted? Does that go on the main page? Or every page? How do you make it work?
Andrea
djr33
03-18-2007, 03:54 AM
You don't need to split it up quite like that.
You can do this--
create menu.htm, which should be a full working page, though I'd advise against the overall tags, like body, head and html, so that when included you only have one set of each of these.
Then use the line--
<?php include('mypath/menu.htm'); ?>
To literally grab the contents of that page and throw them into whatever page you desire the menu to be on, exactly where on the page you desire the contents.
I'm familiar with PHP, so I used that, but SSI and other similar methods would work the same way.
ddadmin
03-18-2007, 09:08 AM
Yep, if your pages are of the .php extension, then you would use something like:
<?php include('mypath/menu.htm'); ?>
within each page to include menu.htm on these pages. On the other hand, if your pages are of .shtml extension (for SSI), you would instead use something like:
<!--#include virtual="mypath/menu.htm" -->
Benedizione
03-19-2007, 01:59 AM
It sounds like even with "php" or the other coding that I would still have to post script on every page of website. Is that right?
Code on every page is okay when there is only a small amount of pages but this website has something like 130 pages so for me to go into every page (which is what I am doing right) is extremely time consuming. Then every time I want to make an update it's a nightmare.
To add to all my time consumption right now, while updating this website I have discovered that someone has violated my website and tripod refuses to do anything about it so I have to take more time to take bigger steps in resolving more issues. Life was easier without computers.
It seems to me though that this css coding would help prevent some of the violation that I am dealing with now because what has happened is that someone "spoofed" my website in a horrific way using my files, guestbook, mailbox and everything making it look like I wrote the page. The simple html coding makes it easy to copy someone else's website. But with css coding some of the coding is hidden. Therefore, no one can copy the page exactly. Am I right?
I really need to find out ways to keep people from doing things like this because I am being harassed by someone over the internet and they do this stuff just to irritate me and intimidate me to remove all my things from the internet. Apparently their life is so boring that they have nothing better to do than try to live their life through me. lol
Andrea
djr33
03-19-2007, 02:40 AM
Yes, each page you want something to happen must be coded to make that happen. There's absolutely no way around this.
What this does is gets the contents of the file each time it loads, so all you need to do is change those 130 files ONE time, rather than changing EACH time you wnat to update the menu. Once the code is in there, the changes to the menu.htm page will update every page (in that those pages load the newest version of the page from menu.htm).
Benedizione
03-21-2007, 04:15 AM
Ok, I am still trying to figure all this out. Have been tinkering around I guess for 2 days studying it and experimenting and either the server's I am using do not support "php" or else I am doing something wrong. Either could be correct.
1) The following code in bold, I need to place on each page where I want my menu to go. Is this right?
2) The "a href" I placed in bold red, do I need a specific page inserted there?
3) Do all my pages including the index page have to have a "php" extension instead of "htm" or "html"?
When I attempted to change my index page to "php", I received a message saying I have no index page.
Andrea
Here is the php script i use for my menus...
function menu($main) {
$full = file_get_contents("http://localhost/includes/menu.txt");
$ready = explode("\r\n", $full);
$count = "0";
while (($count >= "0") && ($count <= count($ready)-2)) {
$one = explode("|", $ready[$count]);
if($main == TRUE) {
echo "<div class=\"item\"><a href=\"". $one['0'] ."\">". $one['1'] ."</a></div>\r\n<div class=\"spacer\"></div>";
} else {
echo "<br /><a href=\"". $one['0'] ."\">". $one['1'] ."</a>\r\n";
};
$count++;
};
};
Then in menu.txt i have
http://domain.com/url|Item name
htp://domain.com/?page|next item name
etc...
boxxertrumps
03-21-2007, 01:35 PM
try making a php page with this on it:
<?php php_info(); ?>
Once you access the page, it should give you something like THIS (http://boxxer.mooo.com/info.php), or your host doesnt support php.
And as for having a specific page there, no. you define all the pages you want in menu.txt, and changing the url so that the function points to menu.txt. You can have two ways to display the data:
echo "<div class=\"item\"><a href=\"". $one['0'] ."\">". $one['1'] ."</a></div>\r\n<div class=\"spacer\"></div>";
Swap the red parts out for whatever markup you have around each menu item.
In menu.txt, on each new line have a url and a peice of text you want to show up as a link, so if you want
<a href="http://www.google.com/">Google</a>
you put this:
http://www.google.com/|Google
into your menu.txt file.
make sure you have the php file with the function included in your pages with the menu:
<?php include "path/to/file.php"; ?>
Then call the function where you want the menu to show up:
<?php menu(TRUE); ?>
Benedizione
03-22-2007, 04:56 PM
What exactly do you mean "it should give you something like THIS"?
I created a page and placed only that code on it and the page comes up blank. Is that good or bad?
http://www.geocities.com/unforgettableelvis/test.php
http://elvispics.tripod.com/test.php
Andrea
try making a php page with this on it:
<?php php_info(); ?>
Once you access the page, it should give you something like THIS (http://boxxer.mooo.com/info.php), or your host doesnt support php.
Benedizione
03-22-2007, 05:05 PM
Umm, I just tried that "php" test page on a domain that I own and pay for and I think I see what you mean now. I bet that geocities and tripod do not support "php" under the "free" domains, only the paid ones! That would make sense, I guess. Bummer for me though. Elvis needs a real home. lol
I am going to work on using that "php" script on my paid domain and see how that goes.
Thanks!
Andrea
boxxertrumps
03-22-2007, 06:45 PM
the "this" is a link to the phpinfo page on my server, which is usually down...
but Its the only example i can give, ill save a copy once i get home.
Its odd, for some reason my server is inaccessable, even though i left it and the internet on this morning...
ill have to check the router and my DNS...
EDIT: temporary power outage.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.