PhP links with variable in the menu ?!

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
Garcimore
Beginner
Beginner
Posts: 3
Joined: Thu Aug 22, 2002 2:03 pm

PhP links with variable in the menu ?!

Post by Garcimore »

First this is a great menu :)

but i have a problem, i would like to put variable links in the menu
as for exemple index.php?s=$s
but in order to work it must be between <? ?>

so my problem is in menu_array.js where you have to put the path of your link
for my script to work it should be something like this:

Code: Select all

<? echo" <a href=\"index.php?s=$s\"> TEST </a>";?>
If i put just index.php?s=$s it won't be recognyse as php variable
is there a way to make the menu undersatnd that it is php ?

Help please :) i would be very thankfull :)
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

This is a server issue. You can tell PHP to parse .js files but it's is not advisable.

It's better to rename your .js file as .php. This will then be parsed through the PHP interpreter by your web server thus allowing you to add PHP variables.

Cheers
Andy
Garcimore
Beginner
Beginner
Posts: 3
Joined: Thu Aug 22, 2002 2:03 pm

Post by Garcimore »

thx i will try !

i have find anyway another way of doing what i want to do :)
dikonstrukt
Beginner
Beginner
Posts: 6
Joined: Fri Oct 04, 2002 4:22 pm

Post by dikonstrukt »

this is exactly the issue i'm having now...

when i renamed menu_array.js --> menu_array.php, though, i get lots of errors.

can you guys provide me with some more detail how it's accomplished?

for example, i need to access the Guestbook from the nav, which is defined as {U_GUESTBOOK} in PhpBB.

i have this in the menu_array file:
,"Guestbook","{U_GUESTBOOK}",,,0

thanks for help!
xMANIGHTx
Super Advanced
Super Advanced
Posts: 53
Joined: Fri Nov 08, 2002 10:17 am

Post by xMANIGHTx »

Generate the array inside the php page instead of the separate js file.
Include it in your page with <script></script> tags and when you have to put php vars, just call the php interpeter <? and put in the vars.
I use ASP so I don't know the right php syntax but it should be quite easy. It's just you usually generate dyn html, so generate dyn js instead ;)
dikonstrukt
Beginner
Beginner
Posts: 6
Joined: Fri Oct 04, 2002 4:22 pm

Post by dikonstrukt »

ok, i put the menu_array.js in the php template header (overall_header.tpl). i don't get any errors, however, it also doesn't work. the {U_GUESTBOOK} variable just shows up as a # sign when you place your mouse over it...

maybe i'm doing the syntax incorrectly. any additional ideas are much appreciated.

thanks!
xMANIGHTx
Super Advanced
Super Advanced
Posts: 53
Joined: Fri Nov 08, 2002 10:17 am

Post by xMANIGHTx »

I don't know exactly PHP syntax.. sorry... by the way, you would have a PHP page (maybe your header template) with generates te final (X)HTML page right?
So you'll have <? echo "<body><div>" /?> and so on... (sorry maybe the syntax is wrong)
Somewhere you have to put a similar PHP instruction to print off the array (instead of including the .js file)
Something like: <? echo "<script type=""text/javascript""><!--"
"menunum=0;menus=new Array();_d=document;function addmenu(){menunum++;menus[menunum]=menu;}function dumpmenus(){mt=""<s"" + ""cript type=text"" + ""/javascript>"";for(a=1;a<menus.length;a++){mt+="" menu""+a+""=menus[""+a+""];""}mt+=""<\/scr"" + ""ipt>"";_d.write(mt)}"
and here add the array, always using echo or wahtever PHP offers instead of ASP Response.Write:
<? echo "addmenu(menu=["menu20",,,160,1,"",SubSt,0,"left",SubFx,0,0,0,"","","","","",.....
and where you have to put the VAR link just put it.
Hope this helps
jvaska
Advanced
Advanced
Posts: 11
Joined: Sat Jul 05, 2003 7:14 pm

Post by jvaska »

has anybody solved this problem (as stated by xMANIGHTx)? this is where i'm stuck, and the menu isn't usable unless i can find some way to deal with this passing of <script type="javascript...

i'd love to know if anybody got through this...

thanks...jv
jvaska
Advanced
Advanced
Posts: 11
Joined: Sat Jul 05, 2003 7:14 pm

PHP SOLUTION

Post by jvaska »

well...i did solve this...i'll post the solution here in case anybody comes across this in the future...

from the menu_array.js file i took out everything below the lines as mentioned previously in this post...

so, beginning with the ///editable properties/// section...i took all of that information and created another file "menu_info.php" and then set up all of my queries in there...

then, i simply call it up in the webpage as another javascript file (yep, with a php file name - it does work)...

voila...and if anybody needs some more help with this i'm happy to help out... jvaska at yahoo dot com ...send me a note...

good luck...jv
xMANIGHTx
Super Advanced
Super Advanced
Posts: 53
Joined: Fri Nov 08, 2002 10:17 am

Post by xMANIGHTx »

:D
Post Reply