processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

$page->if() returns as callable if Page object is passed as "yes" parameter.

Open elabx opened this issue 9 months ago • 2 comments

It called to my attention that when trying to pass a Page object as a "yes" value, I was ending up with the page title as a result of the if(). Sample of the code I was trying to do, basically to add some dynamic values in a template used for rendering an email body.

$body = $this->files->render('mails/mjml/autoresponse.php', [
          'listado_page' => $this->page->if("template=listado|desarrollo|privada",  $this->page ),
]);

So I ended up discovering that the Page object evaluates to true in this is_callable() call in PageComparison.php.

So, I think it would be more helpful to actually expect the Page object as a value?

Thanks!

elabx avatar Mar 25 '25 16:03 elabx

Thanks @elabx I've pushed a fix for this

ryancramerdesign avatar Mar 28 '25 17:03 ryancramerdesign

omg thanks!!!

BereZambrano avatar Mar 28 '25 17:03 BereZambrano