7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » SSBITS: DataObjects as Pages Part 2 tutorial- sidebar issue
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 427 Views |
-
SSBITS: DataObjects as Pages Part 2 tutorial- sidebar issue

23 January 2012 at 3:58pm
Hi everyone,
I've been following http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/ tutorial on my localhost and running into a sidebar problem.
When I use the same method to create a sidebar as tutorial one, an error message shows on my site: [User Error] Uncaught Exception: Object->__call(): the method 'categorypages' does not exist on 'Product'
I know someone had this problem before, but the solution in the discussion didn't solve my problem since I am using the new code ($Category = $this->Categories()->First(); on line 120).
This is the code I added to Product.php for sidebar to appear.
//Return the Title as a menu title
public function MenuTitle()
{
return $this->Title;
}//Ensure that the DO shows up in menu (it is needed otherwise sidebar doesn't show when not logged in)
function canView()
{
return $this->CategoryPages()->canView();
}Does anyone know how to fix it? Thanks very much.
Sam:)
-
Re: SSBITS: DataObjects as Pages Part 2 tutorial- sidebar issue

23 January 2012 at 4:26pm Last edited: 23 January 2012 4:27pm
Hi SamIAm, if you've declared the Category Pages as in the tutorial:
//Relate to the category pages
static $belongs_many_many = array(
'Categories' => 'CategoryPage'
);...then your canView function should look like this:
function canView()
{
return $this->Categories()->canView();
}ie. Change CategoryPages() to Categories() (or whatever you have named the relationship).
Now I'm not 100% on whether that'll make the overall functionality work but I'm pretty sure that's where the error is originating, and that's where I'd start.
-
Re: SSBITS: DataObjects as Pages Part 2 tutorial- sidebar issue

24 January 2012 at 8:21am
Hi Sticks,
Thanks very much for replying. You are right that I need to change
function canView()
{
return $this->CategoryPages()->canView();
}to return $this->Categories()->canView();
However another error came up, [User Error] Uncaught Exception: Object->__call(): the method 'canview' does not exist on 'ComponentSet' Any suggestions on how to fix this?
Thanks very much for your help.
Sam
-
Re: SSBITS: DataObjects as Pages Part 2 tutorial- sidebar issue

25 January 2012 at 8:52am
This is for people who run into the same problem just in case. People on other site have suggested me to use 'return true' for my sidebar purpose and it is working now. Cheers, S:)
| 427 Views | ||
|
Page:
1
|
Go to Top |


