Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

embedding a handler in another

With reference to the handlers and the views generated by crud, I embedded a handler in another, wanting to reuse existing handlers and views.

When editing a parent (say author) I show his children (say books) showing books/admin after authors/edit?id=X appending:

{! books/admin !}

at the end the authors/edit view.

In books/admin handler I intercept the GET parameter "id" and so I can show the books filtered by author.

I do not understand why if I pass the parameter directly to the embedded handler with:

{! books/admin?ida=[id] !}

it results undefined.

Thanks for your help.

Comments

  • Parameters passed directly to handlers are available through the $data array instead of affecting the $_GET values. To check the $data array first and fallback to looking for $_GET['id'] you could say:

    $id = isset ($data['id'])
        ? $data['id']
        : (isset ($_GET['id']) ? $_GET['id'] : false);
    

    You could also check the type of request and set the value that way:

    if ($this->internal) {
        $id = isset ($data['id']) ? $data['id'] : false;
    } else {
        $id = isset ($_GET['id']) ? $_GET['id'] : false;
    }
    

    Hope that helps.

  • edited December 2014

    That helps and solves as always.

    Thank you very much.

Sign In or Register to comment.