Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:26
PhP links with variable in the menu ?!
Poster: Garcimore
Dated: Thursday August 22 2002 - 14:15:39 BST
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:
<? 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
Poster: Andy
Dated: Friday August 23 2002 - 9:49:42 BST
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
Poster: Garcimore
Dated: Friday August 23 2002 - 13:52:18 BST
thx i will try !
i have find anyway another way of doing what i want to do
Poster: dikonstrukt
Dated: Sunday May 11 2003 - 4:07:08 BST
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!
Poster: xMANIGHTx
Dated: Sunday May 11 2003 - 9:59:48 BST
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
Poster: dikonstrukt
Dated: Sunday May 11 2003 - 22:13:46 BST
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!
Poster: xMANIGHTx
Dated: Monday May 12 2003 - 14:13:02 BST
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
Poster: jvaska
Dated: Sunday July 6 2003 - 18:59:54 BST
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
PHP SOLUTION
Poster: jvaska
Dated: Tuesday July 8 2003 - 13:17:49 BST
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