Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svandragt/0f0bb3a33845712b0ecb to your computer and use it in GitHub Desktop.
Save svandragt/0f0bb3a33845712b0ecb to your computer and use it in GitHub Desktop.
$SomeTitle
$ControllerMethod("This doesn't get passed to the method and there is no other way to call ControllerMethod AFAIK?")
<?php
class Some_Controller extends Page_Controller {
private static $allowed_actions = array (
'SomeAction',
);
private static $url_handlers = array(
'SomeAction//$ID/$Name/$Rubbish/$MoreRubbish' => 'SomeAction'
);
public function SomeAction(SS_HTTPRequest $r){
// ...
return $this
->customise(array(
'SomeTitle' => 'SomeTitle',
))
->renderWith(array('SomeAction','Page'));
}
public function ControllerMethod( $argument = null) {
return "ControllerMethod: ($argument)";
}
}
<% loop Things %>
<% include FailingInclude SomeTitle = $Top.Title, ControllerMethod = $Top.ControllerMethod %>
<% end_loop %>
<% include WorkingInclude %>
$SomeTitle
$ControllerMethod("This get passed through")
@svandragt
Copy link
Author

Includes can't directly access the parent scope of the scope active when the include is included. Therefore I have to pass the ControllerMethod via a variable - this then prevents me using the method with an argument, it's always null and if made required results in the following error:

[Warning] Missing argument 1 for Some_Controller::ControllerMethod(), called in framework/view/ViewableData.php on line 363 and defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment