rick Posted August 6, 2015 Share Posted August 6, 2015 I have seen, $user->of(false); // do something with $user $user->save(); $user->of(true); in a few places. But I can't find it's reference in the cheatsheet or doc. What the heck is of() ? Link to comment Share on other sites More sharing options...
adrian Posted August 6, 2015 Share Posted August 6, 2015 It is an alias for setOutputFormatting and it is directly under this one on cheatsheet http://cheatsheet.processwire.com/?filter=$page-%3Eof(true|false) 1 Link to comment Share on other sites More sharing options...
k07n Posted August 6, 2015 Share Posted August 6, 2015 What is of()Baby don't hurt meDon't hurt me no more can't stop singing 5 Link to comment Share on other sites More sharing options...
rick Posted August 6, 2015 Author Share Posted August 6, 2015 Thanks adrian. One follow-up question. Why is this necessary? When searching for 'of(', '->of', etc., no results are found. In fact, the cheatsheet search renames my search to '- of' (greater than is replaced with a space). I don't know what software is used to present the docs, so I don't know how difficult it would be to add an 'un-filtered' search option. Can the references be 'upgraded' to include the 'why'? In the technical docs I've written in the past, I always included the 'what' (what it is), the 'how' (how its used, as in examples), and 'why' (why its used). Currently, the references only provide the 'what', with the ocassional 'how' in response to a specific question. I'm not knocking the docs. As a beginner with PW, the additional information would answer almost all of my noob questions. On a related note, PW has quite a few people that contribute to it's functional development, and it's support here in the forums. I don't have the internal PW knowledge to make those contributions, ...yet. The only skill set I posses at this juncture is assisting in ehancing the docs. I'll be glad to volunteer to extend the reference materials, if that is something y'all have had on the drawing-board. </ thinkingoutloud> Thanks again adrian. 2 Link to comment Share on other sites More sharing options...
thetuningspoon Posted August 6, 2015 Share Posted August 6, 2015 https://processwire.com/talk/topic/10485-simplify-output-formatting-when-saving-pages-via-the-api/ 1 Link to comment Share on other sites More sharing options...
rick Posted August 6, 2015 Author Share Posted August 6, 2015 Y'all might want to grab your sun-glasses. That extra illumination y'all see in here, it's from the light that just came on. Thanks thetuningspoon. 1 Link to comment Share on other sites More sharing options...
Soma Posted August 8, 2015 Share Posted August 8, 2015 Thanks adrian. One follow-up question. Why is this necessary? When searching for 'of(', '->of', etc., no results are found. In fact, the cheatsheet search renames my search to '- of' (greater than is replaced with a space). I don't know what software is used to present the docs, so I don't know how difficult it would be to add an 'un-filtered' search option. Can the references be 'upgraded' to include the 'why'? In the technical docs I've written in the past, I always included the 'what' (what it is), the 'how' (how its used, as in examples), and 'why' (why its used). Currently, the references only provide the 'what', with the ocassional 'how' in response to a specific question. I'm not knocking the docs. As a beginner with PW, the additional information would answer almost all of my noob questions. On a related note, PW has quite a few people that contribute to it's functional development, and it's support here in the forums. I don't have the internal PW knowledge to make those contributions, ...yet. The only skill set I posses at this juncture is assisting in ehancing the docs. I'll be glad to volunteer to extend the reference materials, if that is something y'all have had on the drawing-board. </ thinkingoutloud> Thanks again adrian. I'm the creator of the cheatsheet.processwire.com Searching for "->of" of "of()" works fine. It uses a fuzzy live search clientside with javascript using quicksilver (and some nifty code by jQuery creator John Resig). I remember having some problems with special chars like > but I think some of it was in Firefox but can't recall what. Actually I replace > with a > as this html entity is also used in source. So far I can't reproduce it but maybe you use a sepcial browser or anything else, so please let me know. Link to comment Share on other sites More sharing options...
adrian Posted August 8, 2015 Share Posted August 8, 2015 Or do what I do - don't even both with the actual search functionality - just do a CTRL or CMD + F and type: ->of and let the browser find the text on the page. 2 Link to comment Share on other sites More sharing options...
rick Posted August 8, 2015 Author Share Posted August 8, 2015 @Soma I'm using FF so it could be the issue you speak of. Great work, btw. One question. Is there a setting or query string option to have the complete lists expanded by default? @adrian I use the page content search as well, but wasn't sure whether my search result would be on that page, since I'm new to how everything functions. Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 9, 2015 Share Posted August 9, 2015 One notable difference between setOutputFormatting() and of() is the difference in return value. // setOutputFormatting is chainable and returns the page object $page->setOutputFormatting(false)->set("field", "value")->save(); // of() is not chainable, but does return the previous OutputFormatting status $oldOf = $page->of(false); $page->set("field", "value"); $page->save(); $page->of($oldOf); 3 Link to comment Share on other sites More sharing options...
Soma Posted August 9, 2015 Share Posted August 9, 2015 There's one false too much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now