I'm trying to pass a working variable $count from a controller name dashboard which has authentication.. I tried to insert $this->Auth->allow('_getOnlineUsers'); so that none admin can use the function.
<?php
class DashboardsController extends AppController{
var $name = 'Dashboards';
var $uses = array('Bid', 'Account');
function beforeFilter(){
parent::beforeFilter();
if(!empty($this->Auth)) {
$this->Auth->allow('template_switch');
$this->Auth->allow('_getOnlineUsers');
}
}
function _getOnlineUsers(){
$dir = TMP . DS . 'cache' . DS;
$files = scandir($dir);
$count = 0;
foreach($files as $filename){
if(is_dir($dir . $filename)){
continue;
}
if(substr($filename, 0, 16) == 'cake_user_count_') {
$count++;
}
}
return $count;
}
then inside the same controller I pass the variable to onlineUsers
$this->set('onlineUsers', $this->_getOnlineUsers());
then in my user.ctp I tried the following
<?php echo $count;?>
<?php echo $onlineUsers;?>
nothing happened please help does location make a difference? because here's my destinations controller/dashboards_controller.php
/alberta_template/elements/user.ctp