Passing Arguments

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
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Passing Arguments

Post by Cool_Capybara »

Has anyone had any success with passing arguments using the menu? This may just be a matter of syntax, but I'm trying to pass a value with a link and am not having success.

For example:

Domain.com/page.html?argument=value

In my case, I am passing a php value, so I have something like:

"Domain.com/page.php?argument="<?php echo $value>

...any suggestions as to the support and the syntax?

Thanks!
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Post by Cool_Capybara »

I just noticed that this site does exactly what I am talking about (in the samples); so I guess it's just a matter of syntax...
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Post by Cool_Capybara »

Okay, I have it narrowed a bit...and I find it strange that I can't find the answer easily on a Google search.

But it's pretty much just passing a php parameter with a url using Javascript.

So, I have a php variable, say "ID" that I want to pass along to a new page using javascript (the menu in this case). In Javascript, I have the following:

Code: Select all

addmenu(menu=["Page",

	,,110,1,"",style1,,"",effect,,,,,,,,,,,,

	,"Sub1", "http://",,,1

	,"Sub2", "http://www.domain.com/page.php?"+"ID=<?php echo $ID; ?>",,,1

	])
But of course, that doesn't work. I get a url of

Code: Select all

http://www.domain.com/page.php?<?php
This site uses what I need in its menu examples, so I imagine the syntax is well known...but I can't find an example of it anywhere!

Thanks for the help.
[/quote]
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi,

I'm afraid my knowledge of php is pretty slim, but it looks to me like the menu links to the various examples on milonic.com pass the parameters as literals, like the Standard Demos menu shown below:

Code: Select all

addmenu(menu=["m_standarddemos",,,210,1,"",style2,,"left",effect,,,,,,,,,,,,
,"Link/Image Based - Static","menusample.php?sampleid=2",,,1
,"Link/image Based - Dynamic","menusample.php?sampleid=10",,,1
,"Horizontal Nav Bar - Common","menusample.php?sampleid=1",,,1
,"Link Information Sample","menusample.php?sampleid=5",,,1
])
I don't see any use of php commands or variables in any of the example submenus' URLs. I guess my point is that the menus on the site don't seem to be doing exactly what you want to do, if I understand your goal correctly, so they may not be as helpful as you'd like. I haven't seen an example do quite what you want to do (not to say they don't exist). I know that it's not much trouble to incorporate a javascript variable into the URL field of a menu item definition. Could you do something to move the value of your php variable ($ID) into a javascript variable as an intermediary, then use that javascript variable in your menu item's URL? Just a thought. I know that's probably not much help, but it's all I got.

Kevin
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Post by Cool_Capybara »

Thanks for your reply.

Damned, you're right. Still, this HAS to be a common requirement and is DEFINTELY possible. I just can't figure the @#$%!! syntax out!

Any other ideas?

Thanks in advance!
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi again,

Again, I'm not very good with php (although I hope to learn soon). But if I understand the basic idea, php exerts it's effect by being preprocessed through a server-side php interpreter, before the page is rendered... or something like that... right? It seems like your php code is not being interpreted at all, so what you end up with is the result of treating your php code as a simple literal string in javascript. Is it the .php filename extension that invokes the interpreter? I.e., if your menu arrays are defined in an external .js file (as is the norm here; e.g., menu_array.js), will your psp syntax even be preprocessed/interpreted? I seem to recall reading somewhere on this forum that renaming your external .js file to .php will force it to go through the php preprocessor (... interpreter... whatever). Maybe then your code will be interpreted correctly???

(To whomever wrote the post where I read that bit of wisdom, I apologize if I seem to be stealing your thunder. I searched, but can't find the thread where I read that in these forums, so I can't give proper attribution. Then again, I also can't shirk responsibility if it doesn't work! Maybe I read it somewhere else... Maybe I'm going bonkers... It's late... I have a toddler... which is why I have to be up so late to get my work done... begging the question of why am I screwing around in on-line forums, when I should be working? Back to work.) ;)

A stab in the dark...

Kevin
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Post by Cool_Capybara »

Hmmm... not a bad idea. Yes, the php code is interpreted inline. It's invoked by <?php or <? or <script=php> etc. but even if it wasn't being invoked, I would expect to see the address as a literal. In my case, it's being cut off. I get:

domain.com/page.php?<?php

Not sure why it stops at the space even when in the double quotes.

Still I can see your idea possibly working. I can make the whole menu a php file and run javascript within the php file. I would then include the php file in my main page. I may just give that a try. Thanks for the suggestion.
Cool_Capybara
Beginner
Beginner
Posts: 8
Joined: Tue Nov 05, 2002 2:17 am

Post by Cool_Capybara »

Kevin -- just to let you know, it worked like a charm! Thanks for the suggestion! :D
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Cool! Glad it worked. Although I was just parroting something I read elsewhere. Even so, I'll have to keep it in mind when I start delving into php.

Kevin
F. Jeffe
Beginner
Beginner
Posts: 2
Joined: Thu Nov 14, 2002 7:37 pm

PHP & MySQL

Post by F. Jeffe »

Hello Cool_Capybara (& Kevin),


I also got into troubles when I tried to get the menu working with PHP. In my case the link I try to invoke within the menu has to be something like:
link.php?init=$init&volgord=offno. As you can see init should be replaced by data submitted when loggin in on the website. The problem you struggled with seems to be in the same order and I understood from your digital conversation that some achievement has been made.
Could I be so brutal as to ask you to explain how you did it and even perhaps have the code for it? I would be much obliged since I am working on this for two whole days and don't seem to get any further with it.

Hope to hear from you...


F. Jeffe
Rijswijk (the Netherlands)
jbreslow
Advanced
Advanced
Posts: 28
Joined: Mon Oct 14, 2002 10:04 pm

Post by jbreslow »

Works for ColdFusion too... making the .js file into a .cfm allowed me to pass variables to the menu without a problem.


Thank you sooo much!!!!
Post Reply