O'Reilly logo

MODx Web Development by Antano Solar John

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Snippet and chunk basics

Snippets are executable PHP code objects that provides some functionality when called.

In the previous example, NewsEditor is a snippet. The only content of the Post a Blog! page was the call to the NewsEditor snippet; the snippet takes care of displaying a form and storing the values entered through it as a new document. There is a whole chapter on Snippets in this book (Chapter 8, Snippets). In this section, you will learn the bare minimum about snippets that is necessary to follow along in the ensuing chapters.

Generating output

Most snippets return an output that gets shown in the template at the same location from which the call to the snippet was made.

Such output can be returned by snippets in two ways:

  • Return the HTML: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required