PDA

View Full Version : Need Help with PHP menu



jamslive
11-10-2008, 11:48 PM
hi
1 - i'm using php code for attaching multiple page with one menu.
in the menu page - <? function menu() { ?>
end of page
<?
}
?>

in the the page calling the menu - <?php
include ("menu.php");
menu();
?>

- lets say that the page locate at /public_html/my domain/test/test1
and the menu is at /public_html/my domain

my qustion is - how to change the php code to call the menu frome the root?

thank you
domain name - free-sharing.com

Vasili
11-10-2008, 11:59 PM
Thread Moved To Proper Forum

Collectors-info
11-11-2008, 08:46 AM
LINK (http://www.vodahost.com/vodatalk/212944-post384.html)

jamslive
11-11-2008, 10:54 AM
I read the instruction and i get this notice when publishing the files:
"Fatal error: Call to undefined function menu() in /home/my_username/public_html/you10/Products/index.php on line 4"

*. link to the menu file - http://you10.net/menu.php
the code at start of page -
<? function menu() { ?>
at the end
<?
}
?>

*. link to page including the menu file - http://you10.net/Products
the code is - <?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/home/my_username/public_html/you10/menu.php";
include($file_to_include);
menu();
?>


please - where is my mistake?

thank you

Karen Mac
11-11-2008, 04:17 PM
on the page you want the menu to appear try simply using this

<?
include('menu.html');
?>
in an html box

The other code goes on the page with the menu on it all by itself.

Karen

jamslive
11-11-2008, 04:54 PM
i tried this code and its work well if we calling the menu from the same folder, but i want to call the menu from another folder..
thank you

davidundalicia
11-11-2008, 05:06 PM
depending on how many folders you have, the simple answer is to copy the menu page to the other folders.

jamslive
11-11-2008, 05:22 PM
I have many folders

Collectors-info
11-11-2008, 06:10 PM
If your main munu is in the public_html area, the link to the post above should work fine.

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/include_path/menu.php";
include($file_to_include);
menu();
?>



.

jamslive
11-11-2008, 06:43 PM
i have severals domains on my server, so for every domain i have different folder in my public html.
i specify the locations needed top above.

thank you

davidundalicia
11-11-2008, 06:57 PM
This is the corect code:

If the menu is in your public_html folder then leave out the "include_path"

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/menu.php";
include($file_to_include);
menu();
?>

jamslive
11-11-2008, 07:02 PM
my menu is not at the public_html folder.
please see top above

thank you

davidundalicia
11-11-2008, 07:16 PM
This is the corect code:

If the menu is in your public_html folder then leave out the "include_path"

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/menu.php";
include($file_to_include);
menu();
?>

Well please put it there and the above will work...............

davidundalicia
11-11-2008, 07:22 PM
- lets say that the page locate at /public_html/my domain/test/test1
and the menu is at /public_html/my domain

my qustion is - how to change the php code to call the menu frome the root?

thank you
domain name - free-sharing.com
[/SIZE]

And here is the code from the root:

<?
include('menu.html');
?>



<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/include_path/menu.html";
include($file_to_include);
?>

Extracted from a post by Navaldesign: (http://www.vodahost.com/vodatalk/212944-post384.html) and mentioned by Chris:

jamslive
11-11-2008, 07:38 PM
the code now as you suggested-for the path public_html/you10...
<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/you10/menu.php";
include($file_to_include);
menu();
?>
i get the same result
thank you

davidundalicia
11-11-2008, 08:05 PM
Menu page code - page html - start of page

<? function ppmenu() { ?>

End of page

<?
}
?>

Page code in html box

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/ppmenu.php";
include($file_to_include);
ppmenu();
?>

Please note that I DID NOT include the folder at the end.........
The menu page is in my public directory
and the page is in another folder.

If you code correctly, you will get the correct result.

The above has been run and tested OK

jamslive
11-11-2008, 08:51 PM
Mr david
i dont want to use my public html folder as source of menues.
as i said, i have several domains on my server and every domain has a different folder, it's will not be comfortable to use the root folder for...
i want to use the root folder associat with the domain - /public_html/domain_name/menu.php

for your last suggest above ,in the public_html its work well...
thank you

davidundalicia
11-11-2008, 08:59 PM
James, please call me david.

Unless you have more than one account, then you will only have one public_html directory/folder

I have 20 or so different domains and each domain has many different folders
and I use the sytem that I have shown You without any problems.

I have many different menues and all I do is change the menu name as you might have noticed above.

good luck with your site.

jamslive
11-11-2008, 09:54 PM
David
now its work but i cant see the image? test menu (http://you10.net/Products/)
you have an idea for this problem?

i noticed that in the source html code of the page that call the menu,asking the image from the same folder that the page are.

<img src="bv01239.gif"


thank you

davidundalicia
11-11-2008, 10:57 PM
I have had a look at the test page and links are working OK, but what image are you referring to ?&#191;

jamslive
11-11-2008, 11:01 PM
its Bv shapes feture located on the menu page
thank you

Collectors-info
11-12-2008, 06:13 AM
Hi, its working here http://you10.net/bv01239.gif (1 directory down) But might be worth seeing if the site is enabled under hot link protection in your cpanel.

jamslive
11-12-2008, 08:56 AM
hi and thank you
will you be kind to explain the " hot link protection " issue ?
and how i can solve it?

* - i understand that the page calling the menu from (1 directory down)
but how can we tell the codet to upload the image from 1 or 2 down directory ?

thank you

navaldesign
11-12-2008, 11:04 AM
When the menu page also has an image, the same considerations (regarding the menu itself) are also valid for the images.

Let's suppose that you have published the menu in your public_html/domain_name/foldername (IF you publish in a subfolder)

Publish the menu page. This way, the image is also uploaded.

Then, go back in BV and insert an Image object in your page. Make it the same dimensions as the shape, and in the source field of the dialog box insert :
<? echo $_SERVER["DOCUMENT_ROOT"]."/foldername/bv01239.gif";?>

Publish again.

At this point you should be done.

jamslive
11-12-2008, 10:27 PM
i think i saw somewhere in the forum, your instraction about the simple way to use the php menu code from the same folder.
i think the main idea is to use it and it will be comfortable changing in the future.
if i use Bv nevigation bar menu (image for every button)- its a lot of work to customize the menu page - more than that i think when i will need to change the menu page ,it's will take alot of time.????

thank you

davidundalicia
11-12-2008, 10:39 PM
You can find it here (http://www.vodahost.com/vodatalk/bluevoda-tips-tricks-shortcuts/15764-single-menu-page-bv-php.html)
and it uses the same sort of code that you have seen above, only shorter.

navaldesign
11-12-2008, 10:51 PM
Your best bet is to publish the menu in the same folder(s) as the pages that are using it.

In this case, publish the menu page as html (in example : menu.html)
and make this VERY simple include code:

<?
include 'menu.html';
?>

And you are done.

jamslive
11-17-2008, 11:07 PM
thank you very much (David (http://www.vodahost.com/vodatalk/members/davidundalicia.html),vasili (http://www.vodahost.com/vodatalk/members/vasili.html) and naval (http://www.vodahost.com/vodatalk/members/navaldesign.html)).wonderful job
for helping me solve this php menu issue.
i used that code supplied by David-
Menu page code - page html - start of page

<? function ppmenu() { ?>

End of page

<?
}
?>

Page code in html box

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/ppmenu.php";
include($file_to_include);
ppmenu();
?>
its work fine in different folder but i customized the menu just with HTML elements
NO images,NO shpes

thank you

jamslive
01-18-2009, 12:26 AM
some one can help me with this instruction?
because its dose'nt work for me or maybe i didnt understand what exactly to do


thank you very much (David (http://www.vodahost.com/vodatalk/members/davidundalicia.html),vasili (http://www.vodahost.com/vodatalk/members/vasili.html) and naval (http://www.vodahost.com/vodatalk/members/navaldesign.html)).wonderful job
for helping me solve this php menu issue.
i used that code supplied by David-
Menu page code - page html - start of page

<? function ppmenu() { ?>

End of page

<?
}
?>

Page code in html box

<?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/ppmenu.php";
include($file_to_include);
ppmenu();
?>
its work fine in different folder but i customized the menu just with HTML elements
NO images,NO shpes

thank you

thank you

navaldesign
01-18-2009, 06:18 AM
Your best bet is to publish the menu in the same folder(s) as the pages that are using it.

In this case, publish the menu page as html (in example : ppmenu.html).

Do NOT place any code in the ppmenu page (if you already have some, REMOVE it)

Then use this VERY simple include code in your pages:

<?
include 'ppmenu.html';
?>

And you are done.

jamslive
01-18-2009, 08:05 AM
thank you Sir

i thought that the all idea with "menu include" is to save customizing in the future and with the simple code i will have to work very hard to change it .
my site includes 1200 pages with many folders...
now all my pages with that code
" <?
$file_to_include = $_SERVER['DOCUMENT_ROOT']."/ppmenu.php";
include($file_to_include);
ppmenu();
?> "

jamslive
01-19-2009, 04:42 PM
heelp please

navaldesign
01-19-2009, 09:43 PM
Please follow these steps:

1. Create a folder in your public_html, called "includes"
2. Publish the menu in this folder. Do NOT add ANY code at all in the menu page. For this example, i will suppose that your page is "ppmenu.php".
3. In the (1200!) pages, add this code in the html box:

<?
include '/home/cpusername/public_html/includes/ppmenu.php';
?>

That's all.

Please note that the include methid can NOT display images, so if you have a BV nav bar, which uses buttons (images), those will not appear if the menu is called from another folder. There is a remedy to this, by handcoding the menu page and making the image paths absolute URLs.

Since i consider this to be hard for users without cosing experience, i believe that the solution of publishing the menu page in 10 or 20 folders would not be that hard.

If you insidt, take these steps, AFTER you have published the page:

1. In your BV ppmenu page, right click the menu itself, and select HTML.
2. Copy the menu code.
3. Insert a html box (yes...) in the menu page. Double click it and paste the copied code in it.
You will see the code contains the image paths, in fact it will be looking something like:

<table border="0" cellpadding="0" cellspacing="0" id="NavigationBar1">
<tr>
<td align="left" valign="top" width="124" height="30"><a href=""><img id="bv01001" src="bv01001.gif" alt="" align="top" border="0" width="124" height="30"></a></td>
</tr>
<tr><td height="4"></td></tr><tr>
<td align="left" valign="top" width="124" height="30"><a href=""><img id="bv01002" src="bv01002.gif" alt="" align="top" border="0" width="124" height="30"></a></td>
</tr>
<tr><td height="4"></td></tr><tr>
<td align="left" valign="top" width="124" height="30"><a href=""><img id="bv01003" src="bv01003.gif" alt="" align="top" border="0" width="124" height="30"></a></td>
</tr>
<tr><td height="4"></td></tr><tr>
<td align="left" valign="top" width="124" height="30"><a href=""><img id="bv01004" src="bv01004.gif" alt="" align="top" border="0" width="124" height="30"></a></td>
</tr>
</table>

Wherever you see images, like src="bv01004.gif" replace the source path with:

img id="bv01004" src="http://maindomain.com/includes/bv01004.gif"

Note the standard added part in blue color. Of course, replace maindomain.com with the real main domain name.

Watdaflip
01-20-2009, 05:11 AM
You can move the file behind your public html and it will still load

You can upload it to say

/home/cpanel_username/menu.php

And then include that path...

include("/home/cpanel_username/menu.php");

Just make sure you change "cpanel_username" to your actual cpanel username.

Note you will have to edit the image path and make sure it uses an absolute path, not just relative. But assuming you don't have any hotlink protection enabled you can include the same menu on all your sites and it will load the images off of one.

Also if you did have your menu uploaded at
/home/username/public_html/menu.php

and wanted to load it at
/home/username/public_html/new_folder/menu.php

on files in the "new_folder" directory you can use
include("../menu.php");
and it will go back a directory (on for each ../, so you could do ../../../, etc) and look for menu.php

myjaydee
01-22-2009, 04:52 PM
I've been trying to sort out my menu for months now as I'm building a large site, so tried most of the suggestions here and dozens of others from online. Found this thread and figured it just might work. I used Naval's suggestion.

However, it does not work with javascript menus --- on it's own.

***************
You need to upload the menu into each folder in the first instance in order to get the jsscript into the folder to read. Then delete the menu from each folder leaving behind the js file.

It then seems to work brilliantly.

I haven't found the same problem with other types of includes.

**************************

Fingers crossed I've got it right! Perhaps someone else can clarify this and then put a special thread out in order to help others out there?

navaldesign
01-22-2009, 05:06 PM
Actually, if you include the js menu through a cal in the "head" of the menu page, you need to edit the path to be "/home/cpusername/public_html/js_path/jsname.js " other wise the js is not included. This is the reason you need to upload the js to each folder.

If instead the js was INSIDE the page of the menu (as code) then it would be also included without further changes.

myjaydee
01-27-2009, 04:04 PM
Actually, if you include the js menu through a cal in the "head" of the menu page, you need to edit the path to be "/home/cpusername/public_html/js_path/jsname.js " other wise the js is not included. This is the reason you need to upload the js to each folder.

If instead the js was INSIDE the page of the menu (as code) then it would be also included without further changes.


Hi Naval,

I know you replied to this a few days ago but just found it. I am using BlueVoda's own MenuBar for this and when I tried to copy the code into the menu page it came up with errors.

Can you please explain the first option for me? It sounds interesting and that way I won't forget to add and subtract the menu from every directory. Thanks in advance.