Jump to content

Recommended Posts

Posted

Hi There, I'm following the oop cms tutorial and am trying to get the login/logout working before I go any further.

 

The error I get is

'Fatal error: Call to undefined function getAlerts() in /Applications/MAMP/htdocs/login/views/v_login.php on line 16'

 

Line 16 of v_login is:

 

<?php
				$alerts = $this->getAlerts();
				if ($alerts != '') { echo '<ul class="alerts">' . $alerts . '</ul>'; }
			?>

 

In the m_templates file the getAlerts function had alerts as alert, so I changed that and the error msg in netbeans went away, but my browser is still giving me the error.

 

Curious if anyone has run into this.

 

Jessica

Posted

here is the m_templates - and thanks for the speedy reply!

<?php

/*
Template Class
Handles all templating tasks - displaying templates, alerts & errors
*/

class Template
{
private $data;
private $alertTypes;

/*
	Construtor
*/
function __construct() {}

/*
	Functions
*/
function load($url)
{
	include($url);
}

function redirect($url)
{
	header("Location: $url");
}

/*
	Get / Set Data
*/
function setData($name, $value)
{
	$this->data[$name] = htmlentities($value, ENT_QUOTES);
}

function getData($name)
{
	if (isset($this->data[$name]))
	{
		return $this->data[$name];
	}
	else
	{
		return '';
	}
}

/*
	Get / Set Alerts
*/
function setAlertTypes($types)
{
	$this->alertTypes = $types;
}
function setAlert($value, $type = null)
{
	if ($type == '') { $type = $this->alertTypes[0]; }
	$_SESSION[$type][] = $value;
}
function getAlerts()
{
	$data = '';
	foreach($this->alertTypes as $alerts)
	{			
		if (isset($_SESSION[$alerts]))
		{
			foreach($_SESSION[$alerts] as $value)
			{
				$data .= '<li class="'. $alerts .'">' . $value . '</li>';
			}
			unset($_SESSION[$alerts]);
		}
	}
	return $data;
}
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...