Jump to content

Recommended Posts

Posted

Hi,
just trying to clear knowledge so far.
I have a template with a "utenti" users field.
I can get the desired pages with

$pages->find("template=xx,utenti=$myuser")

But using the api I have to do

if ($page->utenti->has($myuser)) ...

I have trouble understanding the differen for the same expression has and =, why not using *= (contains) in the selector? Or $page->utenti = $myuser?

Thanks

Posted

I have to warn I do not have much knowledge.... but did you try:

$pages->find("template=xx,utenti={$myuser}")

or perhaps

$pages->find("template=xx,utenti=".$myuser)

Posted
if ($page->utenti->has($myuser)) ...

/**
 * the current page with a Pagefield multiple named utenti has $myuser.
 * ($myuser should be User or Page)
 * So this depends on the selected or checked state of the field.
 */

so, does the Pagearray (those selected in the page) contains $myuser

--------------------------------------------------------
 $pages->find("template=xx,utenti=$myuser")

/**
 * Find pages with the template named xx and pages should have $myuser in the utenti field.
 *
 */
  

$myuser used here will echo the ID of that Page/User. But it's actually an Object derived from Page. The print/echo of the ID is done internaly with some magic.

Posted

Ahh! The magic! Usually I do not cosider it as often as I should... ;)

Thanks @bwakad && @martijn !

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
  • Recently Browsing   0 members

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