Remember me? forgot password | register

SilverStripe Forum

10688 Posts in 2795 Topics by 1518 members

Jump to:

Site Builders

If this is your first visit, you will need to register before you can post. However, you can browse all messages below.

Community » SilverStripe Forum » Site Builders » Pass Variables in a Query String?
Page: 1 go to end Reply
Author Topic: Pass Variables in a Query String? 101 views
  • Garrett
    Garrett's avatar
    Community Member
    63 posts

    Pass Variables in a Query String? Link to this post

    Pass Variables in a Query String?

    Hi,

    What is the best way to pass variables from page to page (template to template) in Silverstripe?

    I'm on a page which lists clients, and I want to click on the client and pass that client's name to a page whose controller takes the name and get all the projects for that particular client from the database.

    The link is "projects-by-client?Client=Client1". In my ProjectsByClient controller, I have the following function:

    function ProjectsByClient($Client) {
    $whereStatement = "ProjectClient = '".$Client."'";
    return DataObject::get("ProjectPage", $whereStatement);
    }

    Thwe query works fine if you hard-code a client name. But my controller is saying "missing argument" when I try to pass it in dynamically. How can I pass the client name to the controller?? Seems like this should be easy.

    Thanks in advance,
    Garrett

    101 views
go to top Reply

Currently Online:

François

Welcome to our latest member: lorem