Manaus Posted March 5, 2014 Posted March 5, 2014 Hello, I cannot completely understand the of() function. The field is text, textformatter is, say, Markdown. On saving, I put markdown code, why the need of setting of(false) on writing? Why the need to format values in input? Thanks! 1
kongondo Posted March 5, 2014 Posted March 5, 2014 Quick response.... By default, output will be formatted according filters you may have defined with the field. If you are modifying the values of a page's custom fields, you will need to call $page->setOutputFormatting(false) before doing so. This turns off output formatting, which ensures that saved values don't already have runtime formatters applied to them. ProcessWire will throw an error if you attempt to save formatted fields. http://processwire.com/api/variables/page/ 1
Martijn Geerts Posted March 5, 2014 Posted March 5, 2014 Output Formatting is basicly what it says. When you attach a TextFormatter to a field, Clean text from the database goes through the TextFormatter & changing the text on output. So **bold** wil be changed to <strong>bold</strong> when you use it. (TextformatterMarkdown) Say if you save the page with data, you must be sure that the saved text is clean. You want to save **bold** to the database, and not <strong>bold</strong> (TextformatterMarkdown). Setting of(false) will put all Formatters off, so clean text storage is insured. offtopic: $page->setOutputFormatting(true|false) $page->getUnformatted("field") 5
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