Jump to content

ZF: Controllers Showing Up Blank


Swamp56

Recommended Posts

I've been making a forum system with Zend Framework for a little while now (I originally used my own OOP framework, but decided this was easier ;) ).

 

Ok, so I extended the Zend_Controller_Action class and made my own version, as is shown here.

 

If you notice, I have instantiated a class called Messages, which is for the private message system that I'm creating. The issue is that when I instantiate that, everything goes blank; I can't access any controllers. The code for that class is here. Please note that it's a bit messy at the moment as I'm not even close to being done with it.

 

I have tried emptying the class by having no functions to no avail. I can't figure out what the hell is going on that would make all of my controllers blank. I checked the source and there's nothing as well. I have asked fellow programming friends and they were stumped too.

 

Any help is greatly appreciated  ;D !

Link to post
Share on other sites

You likely have a fatal parse or fatal runtime error. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you with errors it finds. Those two settings must be set before your code is parsed in order to help show fatal parse errors because you code is never executed in that case.

 

And not many people are going to visit links you put in your post. If you want someone to examine your code you will need to post it in the forum.

Link to post
Share on other sites

You likely have a fatal parse or fatal runtime error. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you with errors it finds. Those two settings must be set before your code is parsed in order to help show fatal parse errors because you code is never executed in that case.

 

And not many people are going to visit links you put in your post. If you want someone to examine your code you will need to post it in the forum.

 

I've done both of those things as well as allow ZF to throw exceptions in case of any error.  Here is the code that I linked:

 

/application/usr/models/Controller.php

<?php

/**
* @author C. Fitzpatrick
* @copyright 2009
*/

class Controller extends Zend_Controller_Action
{
public function init()
{	
	// Instantiate various objects
	$this->session->info = new Zend_Session_Namespace('info');
	$this->users = new Users;
	$this->messages = new Messages;

	// Retrieve variables from index 
	$this->smarty = Zend_Registry::get('smarty');
	$this->config = Zend_Registry::get('config');

	// Assign variables into smarty
	$this->smarty->assign('site_name', $this->config->site->name);
	$this->smarty->assign('site_url', $this->config->site->url);
	$this->smarty->assign('users', $this->users);
	$this->smarty->assign('session', $this->session);

	// Register permissions if a user is set
	if (isset($this->session->info->user_id))
	{
		$this->permissions = $this->users->returnUsersGroupPermissions($this->session->info->user_id);

		// Make sure the class returns the permissions as an array and not null
		if (is_array($this->permissions))
		{	
			$this->smarty->assign('permissions', $this->permissions);			
		}
	}

}
}

?>

 

/application/usr/models/Messages.php

<?php

/**
* @author C. Fitzpatrick
* @copyright 2009
*/

/*
* Messages class handles all of the private message
* functions for the forum
* 
* @author C. Fitzpatrick
* @version 1.0
* @access public
*/
class Messages extends Zend_Db_Table_Abstact
{
/*
 * @var object
 * @access private
 */
private $database;

/*
 * void __construct()
 * 
 * Constructor method for the Messages class,
 * allows the database to be initialized.
 * 
 * @access public
 * @return void
 */
public function __construct()
{
	$this->database = Zend_Registry::get('database');
}

/*
 * int returnNumNewMessages(int $userId)
 * 
 * Returns the number of new private messages
 * that a user has.
 * 
 * @param int $userId
 * @access public
 * @return $this->database->fetchAll($query)
 */
public function returnNumNewMessages($userId)
{
	$query = "SELECT COUNT(*) FROM `messages` WHERE recipient='$userId' && viewed='0'";

	return $this->database->fetchAll($query);
}

/*
 * bool composeMessage(int $username, int $recipient, string $message)
 * 
 * Composes a message between 2 members, and returns true if sent and
 * false if not sent
 * 
 * @param $username
 * @param $recipient
 * @param $message
 * @access public
 * @return bool
 */
public function composeMessage($username, $recipient, $message)
{

}

/*
 * bool deleteMessage(int $id)
 * 
 * Deletes a message from a users inbox
 * 
 * @param $id
 * @access public
 * @return bool
 */
public function deleteMessage($id)
{

}

/*
 * array returnMessageInformation($id)
 * 
 * Returns message and post information for a
 * specific message by id
 * 
 * @param $id
 * @access public
 * @return array
 */
public function returnMessageInformation($id)
{
	$messagesQuery = "SELECT * FROM `messages` WHERE message_id='$id'";
	$postQuery = "SELECT * FROM `posts` WHERE section='pm' && tid='$id'";

	return array('messageInfo' => $this->database->fetchAll($messagesQuery), 'postInfo' => $this->database->fetchAll($postQuery));
}
}

?>

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.