Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Pass Variables in a Query String?


Go to End


13 Posts   8928 Views

Avatar
Garrett

Community Member, 245 Posts

12 August 2008 at 1:34am

Actually, I just discovered that I have an even bigger issue beyond the Director:: thing. First off, my SQL needs to be a bit more involved. I don't HAVE an ID for the Client in the ProjectPage table. Just the ClientName. So I need first to pass the ClientID in to the Clients table, get the ClientName there, and then get the Projects from the ProjectPage table which have this ClientName. How to accomplish??

Thanks,
Garrett

Avatar
Garrett

Community Member, 245 Posts

13 August 2008 at 5:51am

Hi--

Why do you think I am getting an error from "if (isset(Director::urlParam('ClientID'))) { "?

Thanks,
Garrett

Avatar
Willr

Forum Moderator, 5523 Posts

13 August 2008 at 11:28am

Director::urlParam() points to an array such that the url equals www.yoursite.com/URLSegment/Action/ID/OtherID so unless you tell SS which one is 'ClientID' it has no idea!

How are you trying to pass the client id? eg if you are doing www.yoursite.com/clients/show/12 you would need to use Director::urlParam('ID') (as URLSegment = clients/, action = show/) or if you are using PHP Query strings so like www.yoursite.com/clients/show?clientID=12 you can get the clientID via $_GET['clientID'];

Avatar
Garrett

Community Member, 245 Posts

20 August 2008 at 7:37am

Success! Thank you so much for your solution.

NOW: to do the same thing using an Ajax load call rather than a direct link? The Client variable will be in the request, but not in the url, obviously. Possible?

Thanks again,
Garrett

Avatar
SilverRay

Community Member, 167 Posts

29 August 2008 at 3:38am

Subscribed.

For an ajax call, I used this (had to modify it a bit):

http://doc.silverstripe.com/doku.php?id=recipes:ajax_basics

Is that what you meant?

Go to Top