Jump to content
Luis C

ps_categorytree throws exception in Product Page

Recommended Posts

Hey everyone:

I'm having some trouble setting up ps_categorytree module in my store. I hooked the module to a custom hook in order to display it in a different place as per default. I'd like to show it in every page, but I'm getting errors depending on what page I'm accessing. Product page throws an exception: 

Cannot use object of type Category as array

and CMS pages (obviously) throw a no declared "Category" index error

 

Any idea if this can be attained without messing with the core to much?

 

I'm using Prestashop 1.7.6.1

Cheers!

Share this post


Link to post
Share on other sites
28 minutes ago, joseantgv said:

Could you paste the complete error?

Oh wow... 

image.thumb.png.f568f9625c8abcc59881a55e1ae4b55d.png

 

surprisingly enough, the error does not occur right at the top of the template (page). Not even at the beginning of the ps_categorytree template, but after showing the main categories, as it tries to load all subcategories. 

OMG! Right as I was typing the response I found my answer and my 'oopsie', and I've corrected it. 

My bad.

Kids, do NOT be me. Think before posting. 

For anyone wanting to know what happened, here's why you should NOT use $category without knowing what you're doing:

I tried to call $category.id from within ps_categorytree.tpl to determine current category and apply a class to my li and a elements. It obviously works on categories page, but not on the rest of the pages. Corrected it by conditioning it to certain pages, now it works just fine.

Thanks joseantgv for trying to help this fool.

image.png

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More