Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
elabx opened this issue Mar 25, 2025 · 2 comments
Open

Comments

@elabx
Copy link

elabx commented Mar 25, 2025

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!

ryancramerdesign added a commit to processwire/processwire that referenced this issue Mar 28, 2025
@ryancramerdesign
Copy link
Member

Thanks @elabx I've pushed a fix for this

@BereZambrano
Copy link

omg thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants