Jump to content

output formatting


Manaus
 Share

Recommended Posts

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!

  • Like 1
Link to comment
Share on other sites

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/

  • Like 1
Link to comment
Share on other sites

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")
  • Like 5
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...