Jump to content

Somehow selector doesn't work in template


LostKobrakai
 Share

Recommended Posts

I have a cart template, with a pagetable "cart" which holds all the products in the cart. But somehow my selector won't find the cart to a anonymous user, while Lister finds it and my second line of code clearly states, that there is a page with a product of the id 1035. 

Does somebody see what I miss?

$pages->get("template=shop-cart, user=40, session=6b53ec96ea298445183c269bf0d51d54, cart.product=1035, include=all, check_access=0")->id

// returns int(0)

$pages->get("template=shop-cart, user=40, session=6b53ec96ea298445183c269bf0d51d54")->cart->first()->product->id

// returns int(1035)
Link to comment
Share on other sites

get wil get it, regardless of state.

But it only found something as superuser, but not as guest. Not until i changed the settings of the cart-item template (child of cart) to be findable by unallowed roles it worked. So the state is only ignored for the page itself, but not for subfields aka all the pagefields. Even with the check_access selctor.

Link to comment
Share on other sites

$pages->get will not use check_access:
$pages->get("template=shop-cart, user=40, session=6b53ec96ea298445183c269bf0d51d54, cart.product=1035, include=all, check_access=0")->id
 
So sounds expected behaviour to me, as cart.product=1035 performs a find in the scope of the current user. And that find isn't allowed due to access rights.  

little note: When you do a find (not get) and use include=all there's no need to call check_access=0 as that is assumed by that.

  • Like 1
Link to comment
Share on other sites

I just wanted to highlight that subpages aren't affected by your statement "get will get it, regardless of state".

For the selector I tried both simply because it had not worked the way I was expecting it to work. But I never had an issue like this before, so in the beginning I wasn't really aware that the cart-item template could tamper with the result.

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...