[TYPO3-mvc] Access control (very simple) example
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Jan 7 22:58:31 CET 2010
Hi,
> I have a part of a fluid template that I only want to show to people who
> are logged in and in a special group.
>
> Is there a way to do that within the condition of an<f:if> tag? I
> tried various versions but couldn't get it to work.
sure - you have multiple options to do this:
a) provide a basic ACLviewHelper that fills your needs
b) do the ACL checks in your controller and assign a special variable to
the view you can check for lateron. eg:
class Tx_YourExtension_Controller_YourController extends ... {
/*...
*/
public function index() {
$this->view->assign('yourObject',
$this->yourObjectRepository->findAll());
$this->view->assign('hasAccess', $this->hasAccess());
}
/* some comment
*/
private function hasAccess() {
# here your check in php
# return what you need - either a object with further functions to
use in your template or a array or simply true/false;
return $access;
}
}
In your template:
<f:if condition="hasAccess">
#some secure content
</f:if>
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list