Skip to content

Instantly share code, notes, and snippets.

@muskie9
Created February 19, 2016 01:47
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 muskie9/b4738e2ebf5c239a1340 to your computer and use it in GitHub Desktop.
Save muskie9/b4738e2ebf5c239a1340 to your computer and use it in GitHub Desktop.
<?php
class My_Controller extends Page_Controller
{
private static $allowed_actions = array(
'index',
'TestFunction',
);
public function index(SS_HTTPRequest $request)
{
return array(
'MyTemplateVar' => $this->TestFunction($request)
);
}
public function TestFunction(SS_HTTPRequest $request)
{
$filter = ($request->getVar('f'))
? array('SomeAttribute' => explode(',' $request->getVar('f')))
: array();
$objects = MyObjet::get()->filter($filter);
if($request->isAjax()){
return $this->customise(
array(
'MyTemplateVar' => $objects
)
)->renderWith('MyCustomTemplate');
}
return $objects;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment