Single Page in Profile Directory

Permalink
I'm making some updates to the profile section and I wanted to add a new single page to be located at /profile/history/ which would render an account history of the user logged in (via custom queries).

So I created a /single_pages/profile/history.php file and a /controllers/profile/history.php Controller file.

The controller loads in fine, but for some reason calling this:

$u = new User(); 
   if($u->getUserID() == $profile->getUserID())


On my single page 'history.php' gives me this error:

Call to a member function getUserID() on a non-object


Which I believe may be because the profile/controller.php functionality isn't actually getting loaded in? So the $profile variable may be undefined? This is my controlers/profile/history.php file (Just copied from the profile/edit.php file)

defined('C5_EXECUTE') or die("Access Denied.");
Loader::model('user_attributes');
Loader::model('attribute/categories/collection');
class HistoryController extends Controller {
   var $helpers = array('html', 'form', 'date');
   public function __construct() {
      $html = Loader::helper('html');
      parent::__construct();
      $u = new User();
      if (!$u->isRegistered()) {
         $this->set('intro_msg', t('You must sign in order to access this page!'));
         Loader::controller('/login');
         $this->render('/login');
      }
      $this->set('ui', UserInfo::getByID($u->getUserID()));


Any help would be awesome!

 
jordanlev replied on at Permalink Reply
jordanlev
Try changing this in your controller:
class HistoryController extends Controller {

...to this:
class ProfileHistoryController extends Controller {
Flight643 replied on at Permalink Reply
Hey Jordan, thanks for the reply!

I gave that a go and I still am receiving the same error. The controller is definitely being called (if I toss an echo statement in it, it renders).

Also I did just do a triple check and it is the $profile variable not registering, it var_dumps as NULL.
jordanlev replied on at Permalink Reply
jordanlev
Are you setting the $profile variable? I don't see it in the code snippet you posted.