Profile Subpage Error
Permalink 2 users found helpful
I added a subpage named Purchases under the main Profile page in my site (created single page /profile/purchases). The page shows up fine but when I include the call to the profile sidebar I get the following error:
Fatal error: Call to a member function getUserID() on a non-object in .../updates/concrete5.4.1.1/concrete/elements/profile/sidebar.php on line 4.
Here's the code of my purchases.php single page (basically just copied the profile view page and modified it a little):
If I comment out the Loader:element 'profile/sidebar' line the page loads fine, but the profile sidebar doesnt show up obviously.
Anyone have any ideas as to what the problem is and how to fix it?
Fatal error: Call to a member function getUserID() on a non-object in .../updates/concrete5.4.1.1/concrete/elements/profile/sidebar.php on line 4.
Here's the code of my purchases.php single page (basically just copied the profile view page and modified it a little):
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <div id="ccm-profile-wrapper"> <?php Loader::element('profile/sidebar', array('profile'=> $profile)); ?> <div id="ccm-profile-body"> <p><a href="/profile" title="">← Back to Your Profile</a></p> <div id="ccm-profile-body-attributes"> <h2><?php echo t('My Purchases')?></h2> </div> <?php $a = new Area('Main'); $a->setAttribute('profile', $profile); $a->setBlockWrapperStart('<div class="ccm-profile-body-item">'); $a->setBlockWrapperEnd('</div>'); $a->display($c); ?>
Viewing 15 lines of 18 lines. View entire code block.
If I comment out the Loader:element 'profile/sidebar' line the page loads fine, but the profile sidebar doesnt show up obviously.
Anyone have any ideas as to what the problem is and how to fix it?
Forget that. It's not going to work. You had it set up properly.
The problem is that the variable $profile is not initialized for reasons which aren't clear to me at this point.
-Steve
The problem is that the variable $profile is not initialized for reasons which aren't clear to me at this point.
-Steve
> The problem is that the variable $profile is not initialized
> for reasons which aren't clear to me at this point.
Now I remember why! You have to create a controller for your single page. Here's how...
Copy the core controllers/profile/controller.php
...to...
/controllers/profile/purchases.php
Edit that controller and change the class name to...
ProfilePurchasesController
I think that should do it.
-Steve
> for reasons which aren't clear to me at this point.
Now I remember why! You have to create a controller for your single page. Here's how...
Copy the core controllers/profile/controller.php
...to...
/controllers/profile/purchases.php
Edit that controller and change the class name to...
ProfilePurchasesController
I think that should do it.
-Steve
Steve,
That did the trick! Works perfectly now. Thanks a million!
If anyone from the core team is seeing this - this page in the docs should be updated to mention that you have to do this, under the section 'Adding a Page to the Public Profile':
http://www.concrete5.org/documentation/developers/permissions/profi...
That did the trick! Works perfectly now. Thanks a million!
If anyone from the core team is seeing this - this page in the docs should be updated to mention that you have to do this, under the section 'Adding a Page to the Public Profile':
http://www.concrete5.org/documentation/developers/permissions/profi...
Look at the guest views plugin, blocks->login->templates->profile_sidebar.php that should show you how to do it,
Rename your purchases.php to view.php and put it here...
/single_pages/profile/purchases/view.php
-Steve