7939 Posts in 1472 Topics by 944 members
|Go to End|
23 January 2012 at 3:58pm
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()
//Ensure that the DO shows up in menu (it is needed otherwise sidebar doesn't show when not logged in)
Does anyone know how to fix it? Thanks very much.
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:
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.
24 January 2012 at 8:21am
Thanks very much for replying. You are right that I need to change
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.
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:)
|Go to Top|