Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MODx Web Development - Second Edition

You're reading from  MODx Web Development - Second Edition

Product type Book
Published in Feb 2011
Publisher Packt
ISBN-13 9781849513487
Pages 288 pages
Edition 1st Edition
Languages
Toc

Table of Contents (19) Chapters close

Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. What is MODx? 2. Getting Started 3. MODx Basics 4. Templating 5. Authentication and Authorization 6. Content Aggregation 7. Creating Lists 8. Snippets 9. PHx 10. Simple Recipes 11. Creating Snippets 12. SEO, Deployment, and Security 13. Plugins and Modules 14. MODx Revolution

Working of snippets


Snippets are units of code that can be called from a resource or a template.

A snippet can do one or more of the following three things:

  • Return text or HTML

  • Populate template variables

  • Process a chunk and return its value

Almost anything that can be done in PHP can be done using a snippet. However, how you control the output and the flexibility of the snippet depends on how you use the snippet to do one of the preceding activities or a combination of them.

A snippet can be called by using one of the following notations:

  • [[snippetname]]—cached call

  • [!snippetname!]—non-cached call

In a cached call, a snippet is processed once, and whatever it generates is cached and used till the cache is cleared. However, if the page from which the snippet is executed is not cached, the snippet will be processed anyway for every request. Caching may be useful for optimization in situations where the expected output from the snippet does not change frequently.

In a non-cached call, a snippet is processed...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}