Jump to content

New post – All about output formatting in ProcessWire


ryan
 Share

Recommended Posts

In a recent GitHub issue report, I was asked about output formatting in ProcessWire, and where more information could be found about it. I know I've written about it numerous times, and went to locate the documentation page, only to find we didn't have one!  Output formatting is such an important topic, so here is everything you need to know.  I hope you'll find it simple enough, but also useful and thorough— 

https://processwire.com/blog/posts/output-formatting/

  • Like 31
  • Thanks 2
Link to comment
Share on other sites

  • 3 weeks later...
  • 10 months later...

One question I have is: is output formatting on or off in this situation?

$pwUser = $this->wire->pages->newPage([    
  'template'       => 'someTemplate',              
  'name'           => 'someName',
  'someField'      => 'someValue',
]);

A reflection about setting a value when output formatting is ON: The blog says that when it's ON, the formatters will run to check it can be formatted and it will set it to status:corrupted if they can't run. This sounds like good validation to me, which makes me think it might be better advice to do $page->of(true) before setting values, unless you're in a situation where you can really trust your raw data to be valid. Caveat: I note that the example edits are self referential ($page->someField = $page->someField + 'altered') in which case it's clear that output formatting ON is going to cause problems.

 

 

Edited by artfulrobot
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...