31,19 €
MODx is a content management system and PHP web application framework rolled into one. With the ease of a CMS and the extendibility of a framework, MODx allows you to develop professional-looking, intricate websites with its easy-to-use interface and flexible architecture. MODx provides reusable code fragments called snippets, most of which are so generic that, without any modification, they can serve multiple functionalities. The generic nature of the snippets makes it possible to get the perfect customization that is so hard in other CMS.
This book will get web developers up-and-running with MODx. With step-by-step examples and illustrative screenshots, you will be guided through installation, configuration, and customization. By the end of the book, you will have created a powerful, dynamic website by using the individual elements of MODx, without the need for programming know-how.
Starting with a walk-through of how to install MODx, you will quickly learn how to develop your site without having to use any programming language. Logical, step-by-step instructions will show you how to create your own unique site by adding and editing documents using the inbuilt TinyMCE editor. You will change the look and feel of your site by creating your own templates using HTML, CSS, and widgets. By following the example of a blog site, you will learn how to extend your templates to allow rich user interactions through comments, posts, and forms. The book teaches a few code snippets such as Ditto and Wayfinder in detail. These powerful and flexible snippets will enable you to add multiple functionalities to your site. The book will also introduce you to many more snippets that will help you build some of the commonly required web functionalities such as forums and image galleries. You will manage your users with authentication and authorization and make your site user-friendly with user groups, forums, and the use of PHx notations to embed logic in templates.
Through following this easy-to-use, step-by-step guide you will, by the end of the book, have a fully functional, feature-rich MODx site with professional-looking, dynamic web pages that are totally customizable.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 263
Veröffentlichungsjahr: 2011
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First Edition: March 2009
Second Edition: March 2011
Production Reference: 2020311
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-849513-48-7
www.packtpub.com
Cover Image by Asher Wishkerman (<[email protected]>)
Author
Antano Solar John
Reviewers
Thayub Hashim Munnavver
Ravishankar Somasundaram
Development Editor
Swapna Verlekar
Technical Editors
Prashant Macha
Manasi Poonthottam
Copy Editor
Leonard D'Silva
Indexer
Tejal Daruwale
Editorial Team Leader
Mithun Sehgal
Project Team Leader
Ashwin Shetty
Project Coordinators
Poorvi Nair
Zainab Bagasrawala
Proofreader
Dirk Manuel
Graphics
Nilesh R Mohite
Production Coordinator
Kruthika Bangera
Cover Work
Kruthika Bangera
Antano Solar John is a tech evangelist who is passionate about using technology to revolutionize the learning experience.
Antano has always had the unique ability of learning new technologies quickly when confronted with the challenge of helping experts in that domain. As an accomplished tech-consultant, many organizations turned to Antano when they had tried almost everything and given up. He got involved in training accidentally and has since then trained thousands of programmers.
In the early stages of his career when he was a consultant, he first came across MODx in its infant stages. He mastered it and went on to author the first book to be written on MODx. After which he wrote his next book on a Perl MVC framework called Catalyst.
Eventually Antano was delivering @ Learning, Business and Technology solutions. Later, he joined NuVeda Learning Pvt Ltd as the Chief Technology Officer. Here, he co-authored the patent pending learning methodology titled @ CALF(tm) (Continuous Application of Learner's Feedback)
Antano in his free time focuses on research in Cybernetics and Neuro Linguistic Programming (NLP) as he aspires to build—"School of Excellence" with the vision of Patterning Scalable Methods for Unconscious Excellence.
Antano's first technical publication while in college was "Help AI Help You—Swiss Knife of Communication" in which he attempted to use the machine's intelligence as a feedback device of human communications. Following which he authored "802.11 MAC Enhancements—Breaking Barriers of Wireless Speed" which was published in an IEEE Journal.
Some of Antano's other interests include Music, Dance, Martial Arts and Chess. He used to play Chess professionally as a child-teen. Antano also used to run a successful gaming business when he was in high school through college.
He has also won the yahoo hack award twice, once for developing a Collaborative Browsing Mechanism and consecutively for building a Hybrid Search Engine from scratch.
To those who prepared me,
My Mom & Dad—For all the Hope, Faith, Love, and Wise Counsel.
And to those who made it happen.
Thayub Hashim Munnavver has been fascinated by computers and the technologies involved since childhood. He did his tertiary education in Electronics & Communication Engineering at Anna University. Upon graduating, he joined Infosys Technologies Private Limited as a Software Engineer, and worked on the .Net platform, after which he worked as a consultant in Singapore. Currently, he works for NuVeda Learning—a concern that promotes accelerated learning solutions, using technology for people's needs.
I would like to thank my mother without whom none of this would have been possible, and also Shireen and Vinoshini.
Ravishankar Somasundaram has over five years of experience in providing solutions to clients across multiple sectors and domains. Being more passionate about learning and teaching, he too strongly believes that the sole purpose of learning is to make our minds think in different perspectives, and facilitates the same in his training sessions through a blended learning approach mainly focused on how to "learn to learn".
A Junior Scientist in his lower schoolings, in addition to winning several prizes in science projects, being awarded a prize, by a committee consisting of people from ISRO, the Title in an Inter school Science Fest, for a model display on the "Evolution of Airplanes through Aerodynamics", is one of his childhood achievements.
His final-year college project, which was aimed at eliminating the scenario of English alone being the medium of programming in all programming languages, which restricts people who don't know English from getting into the IT field and implementing their ideas, was selected and funded by MIT NRCFOSS, and is considered a landmark.
Being one of the seven people from India and the only one from Tamilnadu as an official third-party developer of Moodle code, Ravi shares his knowledge by helping people on the Moodle official forum and on its IRC, he has also presented a paper in the 9th International Tamil Internet conference on "Moodle: For Enhanced Learning".
Ravi was a Freelance IT Consultant delivering solutions to firms irrespective of Technical, Non-Technical or Business domains; recently he joined Thirdware Technologies as a Technical Analyst and a Chief Architect heading the R&D Division.
Though I am thankful to all of the people I have met till date, for they contributed to the cause of my growth by becoming an inspiration to me, or by personally guiding and pointing me in the right direction when facing challenging situations or by throwing critiques continuously, making me recognize there is always room for improvement in my career and personal life as well, Meeting a few of these people namely Mr.Madhivanan at my lower schooling as Geography teacher, Mr.Baluchamy at my higher schooling as Physics teacher, Mr.L.Sridhar at SISI as my Hardware and Networking course teacher, Mr.Thiyagarajan and MR.Arul at PAV boxing club as my coaches, Mr.Srinivasan at MIT as Project scientist in NRCFOSS as a guide to my final year B.Tech project, Mr.Antano Solar John at Lynus Academy as my facilitator for perl, Mr.Bala Krishnan at NuVeda as CEO, who completely changed the way I looked at and went about doing things, I am indebted to them.
And, of course, I am thankful to my friends Deepak, Karthik Prabhu, Sesha Gopal, Gopinath, Senthil, Siva, Chandru, Venkat, Naveen, Prem, Sarvothaman, Karthikeyan, Rajesh, Pradeep Kumar, Ranjith Kumar, Rajaram, Mangai, Sridevi , Ramya , Shiva Smruthi and more importantly the IRC community and all the wonderful people dwelling there.
Last but the foremost I dedicate all of my accomplishments to my parents, sister, and other relations, for all the faith, hope, love and support.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
MODx is a content management system and PHP web application framework rolled into one. With the ease of a CMS and the extensibility of a framework, MODx allows you to develop professional-looking, intricate websites via its easy-to-use interface and flexible architecture. MODx provides reusable code called snippets, most of which are so generic that, without any modification, they can serve multiple purposes. The generic nature of snippets makes it possible to achieve the perfect customization that is so hard to achieve with other CMSes. This book will have web developers up-and-running with MODx. With the use of step-by-step examples and illustrative screenshots, you will be guided through installation, configuration, and customization of MODx. By the end of the book, you will have created a powerful, dynamic website by using the individual elements of MODx, and without the need for programming know-how.
Chapter 1, What is MODx: In this chapter, you learn the general concepts of web development, and also been assured as to why MODx, as a tool, is a good choice for developing your website. The various development methodologies, especially a CMS and a Web Application Framework are explained. With these briefings on the fundamentals, you will have a clear understanding of what MODx is and why you would want to use it.
Chapter 2, Getting Started: In this chapter, you learn how to set up a working platform for developing websites with MODx that includes the installation and configuration of the prerequisites such as Apache, PHP, and MySQL. To make the process easier, you will use XAMPP, which is a bundle containing all of these packages. Finally, you will install MODx and will verify that everything is set and ready.
Chapter 3, MODx Basics: In this chapter, you learn about resources and containers and how every page that is displayed gets it's content from a resource. You also learn to create, edit, and manipulate resources and manage their configurations, and also receive an explanation of the TinyMCE editor. This chapter also explains each and every configuration option available for documents, and also the general configurable options of the site. Finally, you create a Front Page by using what you have learned, and are introduced to the convenience of the DocManager.
Chapter 4, Templating: In this chapter, you learn about templates, how to create and add them, and the flow of rendering. We learn about template variables and resource specific variables, data types, Widgets, data sources, snippets, and chunks. You also create a template for the site, a snippet from the web, blog functionality, a custom form template for the blog page, and a rich text editor for the blog.
Chapter 5, Authentication and Authorization: In this chapter, you will learn how MODx facilitates authentication and authorization. You will build your site to include user registrations, logins, and user types, and will also set rules on who can do what.
Chapter 6, Content Aggregation: In this chapter, you learn about one very useful snippet, called Ditto. You see how to create aggregation and feeds, and how to create feeds for separate categories. You also learn about tagging and how to tag resources and use them in MODx.
Chapter 7, Creating Lists: In MODx, the simplest way to create lists of all of the resources is by using the [[wayfinder]] snippet. In this chapter, you learn how MODx allows us to create these lists dynamically, and you also learn how to present these lists as menus.
Chapter 8, Snippets: In this chapter, you learn how to use the hundreds of snippets that available, and in detail learn how to use a snippet and navigate its custom functionalities. You also learn how to search for snippets that do not come packaged with MODx, and how to use them. Along the way, you will add the functionality required to post comments and to navigate posts via their posting date.
Chapter 9, PHx: In this chapter, you learn how to format the values in template variables, and also see how to make conditional decisions based on the value of template variables, and accordingly present a different output either from the HTML in the expression or from a chunk or snippet.
Chapter 10, Simple Recipes: In this chapter, we will use what we have already learned to study how certain commonly-required functionalities can be implemented. We will learn how to integrate a forum, include an image gallery, and develop forms that can send mail, create web user profiles, and identify similar posts for blogs.
Chapter 11, Creating Snippets: In this chapter, you learn how to create snippets and the different ways of rendering their output. You also learn how to use the available MODx APIs as well as why you should use them. You create a new snippet for the site to display a random fortune. The snippet accepts a parameter for a chunk and renders the output by using chunks and placeholders. You also learn how snippets can make use of external files.
Chapter 12, SEO, Deployment, and Security: In this chapter, you learn how to optimize the site for search engines. You learn about clean URLs, meta tags, site maps, and other tweaks. Having developed the site on a local machine, you learn, in this chapter, how to deploy it to a remote server. Finally, you look into what has to be done in order to make your MODx site secure.
Chapter 13, Plugins and Modules: In this chapter, you learn about plugins and modules. You learn how to use plugins and how to customize plugins. You also learn how to create new plugins, and analyze the code of the prettify code plugin. Finally, you learn how to use modules by using the Autolink module and plugin.
Chapter 14, MODx Revolution: In this chapter, you take a quick look into MODx Revolution, to understand when to upgrade, what to expect, and how to contribute.
No knowledge of PHP programming or any templating language is needed, but the more advanced chapters towards the end of the book will allow more confident developers to extend their applications even further by creating their own snippets. Software required for this book is only the LAMP Stack and, of course, the MODx installation.
This book is ideal for newcomers to MODx. Both beginners and experienced web developers will benefit from this comprehensive guide to MODx. The more advanced chapters towards the end of the book will allow more confident developers to extend their applications even further by creating their own snippets.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "We can set this right by passing the value of the new template variable using the rtcontent parameter."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Go button to import the database."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code for this book
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
MODx is a content management system and an application framework. MODx makes it quick and simple to create websites that are interactive and that can expose different functionalities, depending on the kind of user visiting the site. The creation of all of this is made possible without the user having any coding background as many of its powerful features work out-of-the-box, without any code changes. MODx and its shipped components are modular and well-abstracted so that the same components provide multiple behaviors, which are determined by how the components are used.
A content management system (CMS) allows you to do the following:
Managing content means allowing a user to create, publish, edit, and organize content. A good CMS assumes that the user has no technical knowledge. Hence, it provides an easy-to-comprehend user interface for managing content. A flexible CMS will maintain ease of use, even for a novice, and yet give much flexibility to the professional. Publishing the content must extend beyond just displaying the content, and should include designing how the content is shown, making the content accessible, and allowing easy search of the content, based on various criteria.
Content management rules allow the management of content to be delegated and distributed from just one user to many. Different access levels can be granted to different groups, and users can belong to one or more of the defined groups.
Managing content is fine, but what exactly is content? A good CMS allows the end user to define what content is. Content can be anything! It can be raw text, pictures, videos, music, or a combination of a few, or all, of them. A necessity in any CMS is to allow the user to define the possible types of content and give such types a name.
An application framework is an integrated platform that makes the process of developing and maintaining applications a lot simpler. Often they support a certain development methodology and provide interfaces and tools to make the development rapid and agile.
An application framework serves the following two primary purposes:
The development of websites has evolved over the years. They initially originated from simple hyperlinked pages that provided a wealth of information, evolving to complex objects being exposed as URLs at runtime. When wanting to develop a site, there are multiple options that one may choose for development. A briefing on the most widely known methodologies follows.
The 'old school' approach is to use a programming language to create a complete site or application from scratch without using any third-party templating system or framework. In this method, there are three layers:
In this architecture, a user requests a page. Every request is processed by executing an appropriate server-side script. A server-side script is any piece of code that is processed and that helps the server to send a response to the client. A common example of a server-side language is PHP. All code that executes in the user's system or the client's system is called client-side script or language. HTML and JavaScript are such client-side languages, as they are processed and rendered by the web browser on the user's computer. Whenever needed, any stored information is fetched by the server-side script from the database, and any new information is saved in the database. This approach is called the Three-Tier Architecture as, generally, the activities of rendering output, processing the script, and manipulating the database are spread across three layers of systems.
One advantage of the conventional three-tier architecture is that it has fewer dependencies. Generally, the only real dependency for such sites is the language itself and the database, if used. Hence, they can be run in any environment that supports the language and, if necessary, the database server. This advantage looks minimal considering the other overheads and the increasing support for CMSs and frameworks among the hosting providers.
The only restriction on what you can do is the limitation of the language itself. Coding everything from scratch, along with the overheads, also brings the flexibility of doing anything exactly the way you want. The only limitation on what can be done and what cannot be done is what is imposed by the language itself. Again, this is not a real advantage as the emerging technologies are being built so abstract that they impose almost no restriction themselves.
The conventional three-tier architecture can be used to develop new development methodologies. Whatever the framework of the CMS may be, beneath the surface, they must all follow the same core rules. Hence, something about these systems takes care of handling requests and generating responses at the lowest layer, which the developer need not worry about. The components that take care of such activities are themselves coded in the conventional three-tier architecture.
Having to reinvent the wheel is a big disadvantage of the conventional three-tier architecture. Any big project will have a common set of functionalities that are repeated. Many projects have, in fact, emulated an existing CMS or framework in the process of building their own tools. This is just repetition of work and time that could have been spent more productively. Most projects written in the conventional three-tier method end up reinventing the wheel, at least for the concepts of "formatting output" and "database abstraction".
Another disadvantage is that the three-tier architecture is error prone. The language allows you to get things done. It doesn't check if they are done cleanly or not. Hence, it is very simple to write code that gets something done, but not so easy to write clean code that gets the same thing done, even in the worst conditions.
