MODx Web Development
()
About this ebook
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 with 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 functionalities. The generic nature of the snippets makes it possible to get the perfect customization that is so hard in other content management systems.
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 installing 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. 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 core 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 which will help you build some of the commonly required web functionalities such as forums and image galleries. 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, by the end of the book you will have a fully functional, feature-rich MODx site with professional-looking, dynamic web pages that are totally customizable.
ApproachThis book is an example-driven tutorial, which will take you from the installation of MODx through to configuration, customization, and deployment. Step-by-step instructions will enable you to build a fully-functional, feature-rich website quickly and without any programming language.
Who this book is forThis book is ideal for those who want to learn to use MODx. Both beginner and experienced web developers will benefit from this comprehensive guide to MODx. 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.
Antano Solar John
Antano Solar is a techie to the core-a tech evangelist who is passionate about using technology to revolutionize the learning experience! Antano has contributed to the open source community in terms of documentation, code, and support, with a variety of platforms based on languages such as PHP, Perl, Lisp, Python, and Ruby. He loves to share his tech excitement with fellow techies and non-techies, and does so through publishing papers, books, and delivering seminars at colleges, universities such as the IIT, and corporate tech events. He has published a paper on enhancing wireless networks in an IEEE Journal. His paper on an engine helping machines understand objectives by meta-modeling, using Neurolinguistic Programming principles and Deep Structure, is considered a landmark. An avid hacker, Antano has won two Yahoo hack-day awards. He recently won the award for developing a Hybrid Search Engine from scratch in 24 hours that uses Machine Intelligence and Social Intelligence to identify, search, and present the information in the required format. Professionally, until recently, Antano was a Consultant and a Trainer providing IT solutions and sessions on VoIP, Networks and Software Plaforms, and Languages. He is currently the Chief Technology Officer at NuVeda Learning. In his current role, he is responsible for the development and deployment of Learning Management Systems that are used by large MNCs globally. He also plays the role of a Chief Architect in the research and development of technologies related to the understanding and measuring of Learning. He is excited by the challenges of using complex technologies such as Artificial Intelligence and Natural Language Processing. Occasionally, when Antano needs to take a "Tech" break, he likes to train and tell stories!
Related to MODx Web Development
Related ebooks
MODx Web Development: Build dynamic websites with MODx PHP application framework and CMS Rating: 0 out of 5 stars0 ratingsPractical Plone 3: A Beginner's Guide to Building Powerful Websites Rating: 0 out of 5 stars0 ratingsLearning Website Development with Django Rating: 0 out of 5 stars0 ratingsLearning Drupal 8 Rating: 4 out of 5 stars4/5Mastering Yii Rating: 0 out of 5 stars0 ratingsDjango 1.0 Web Site Development Rating: 4 out of 5 stars4/5Building Websites with VB.NET and DotNetNuke 4 Rating: 1 out of 5 stars1/5Odoo Development Essentials Rating: 0 out of 5 stars0 ratingsLearning Drupal 6 Module Development Rating: 3 out of 5 stars3/5Symfony 1.3 Web Application Development Rating: 0 out of 5 stars0 ratingsFederated Learning with Python: Design and implement a federated learning system and develop applications using existing frameworks Rating: 0 out of 5 stars0 ratingsOdoo 10 Development Essentials Rating: 0 out of 5 stars0 ratingsBuilding Websites with DotNetNuke 5 Rating: 5 out of 5 stars5/5Getting Started with Knockout.js for .NET Developers Rating: 0 out of 5 stars0 ratingsFuelPHP Application Development Blueprints Rating: 0 out of 5 stars0 ratingsASP.NET 8 Best Practices: Explore techniques, patterns, and practices to develop effective large-scale .NET web apps Rating: 0 out of 5 stars0 ratingsHands-On Enterprise Application Development with Python: Design data-intensive Application with Python 3 Rating: 0 out of 5 stars0 ratingsNode Web Development, Second Edition Rating: 0 out of 5 stars0 ratingsMastering ServiceStack Rating: 0 out of 5 stars0 ratingsDesigning Deep Learning Systems: A software engineer's guide Rating: 0 out of 5 stars0 ratingsPrimefaces Theme development: Create, package, and customize stunning themes using PrimeFaces Rating: 0 out of 5 stars0 ratingsElasticsearch Indexing Rating: 0 out of 5 stars0 ratingsMEAN Blueprints Rating: 0 out of 5 stars0 ratingsMastering KnockoutJS Rating: 0 out of 5 stars0 ratingsDrupal 7 Social Networking: Build a social or community website with friends lists, groups, custom user profiles, and much more Rating: 0 out of 5 stars0 ratingsMastering Go: Leverage Go's expertise for advanced utilities, empowering you to develop professional software Rating: 0 out of 5 stars0 ratingsBuilding Websites with VB.NET and DotNetNuke 3.0: Building Websites with VB.NET and DotNetNuke 3.0 Rating: 0 out of 5 stars0 ratingsFull-Stack React Projects: Modern web development using React 16, Node, Express, and MongoDB Rating: 0 out of 5 stars0 ratingsMastering MongoDB 6.x: Expert techniques to run high-volume and fault-tolerant database solutions using MongoDB 6.x Rating: 0 out of 5 stars0 ratings
Information Technology For You
How to Write Effective Emails at Work Rating: 4 out of 5 stars4/5Algorithms to Live By: The Computer Science of Human Decisions Rating: 4 out of 5 stars4/5Summary of Super-Intelligence From Nick Bostrom Rating: 4 out of 5 stars4/5Learn Algorithmic Trading: Build and deploy algorithmic trading systems and strategies using Python and advanced data analysis Rating: 0 out of 5 stars0 ratingsA Mind at Play: How Claude Shannon Invented the Information Age Rating: 4 out of 5 stars4/5ChatGPT: The Future of Intelligent Conversation Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5The Programmer's Brain: What every programmer needs to know about cognition Rating: 5 out of 5 stars5/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Attention Span: Finding Focus for a Fulfilling Life Rating: 4 out of 5 stars4/5UML 2.0 in Action: A project-based tutorial Rating: 0 out of 5 stars0 ratingsPersonal Knowledge Graphs: Connected thinking to boost productivity, creativity and discovery Rating: 0 out of 5 stars0 ratingsSolution Architecture Foundations Rating: 3 out of 5 stars3/5Information Theory: A Concise Introduction Rating: 0 out of 5 stars0 ratingsQuantum Computing for Programmers and Investors: with full implementation of algorithms in C Rating: 5 out of 5 stars5/5AWS Certified Cloud Practitioner: Study Guide with Practice Questions and Labs Rating: 5 out of 5 stars5/5Machine Learning Interview Questions Rating: 5 out of 5 stars5/5The BPMN Graphic Handbook Rating: 4 out of 5 stars4/5Inkscape Beginner’s Guide Rating: 5 out of 5 stars5/5Who Says Elephants Can't Dance?: Leading a Great Enterprise Through Dramatic Change Rating: 4 out of 5 stars4/5Just Enough R: Learn Data Analysis with R in a Day Rating: 4 out of 5 stars4/5Google Cloud Platform an Architect's Guide Rating: 5 out of 5 stars5/5The Tetris Effect: The Cold War Battle for the World's Most Addictive Game Rating: 3 out of 5 stars3/5The Age of AI: How Artificial Intelligence Will Transform Our World Rating: 0 out of 5 stars0 ratingsA Modern Enterprise Architecture Approach: Enterprise Architecture Rating: 4 out of 5 stars4/5A Vulnerable System: The History of Information Security in the Computer Age Rating: 0 out of 5 stars0 ratings
Reviews for MODx Web Development
0 ratings0 reviews
Book preview
MODx Web Development - Antano Solar John
Table of Contents
MODx Web Development
Credits
About the Author
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code for the book
Errata
Piracy
Questions
1. What is MODx?
Content management system
Manage content
Content management rules
Define content
An application framework
Reusable program components
Abstracting logic from presentation
Web development methodologies
Old school—conventional three tiers
Advantages of the conventional three tiers
Disadvantages of the conventional three tiers
Templating
Advantages of templating
Disadvantages of templating
Application frameworks
Advantages of application frameworks
Disadvantages of application frameworks
Content management systems
Advantages of content management systems
Disadvantages of content management systems
Why MODx?
Why a CMS?
Why an application framework?
So, why Modx?
Overview of the book
Summary
2. Getting Started
Setting up the development environment
Prerequisites
Linux
Windows
MAC
Verification
Downloading MODx
Installing MODx
Creating a database
Starting the installation
Installation status and diagnostics
Documentation
Official documentation
Community-driven documentation
Getting support
Web forums
IRC
Summary
3. MODx Basics
Site configuration
Configuring the site
Default Manager interface page
Noticing and fixing errors and warnings
Changing the name of the site
The basic element of MODx: Documents
Containers
MODx Manager interface
Using the HTML editor
Creating the Front Page
QuickEdit module
Documents revisited
Editing documents
Document properties
General tab
Page Settings
Meta Keywords tab
Preview tab
Summary
4. Templating
Changing the template of a document
Creating a new template and giving it a category
HTML
CSS
Steps to create the new template
Making the Home Page use the created template
Choosing a default template
Introducing template variables
Modifying the template to add dynamic behavior
Changing existing templates
Template variables
Creating template variables
Template variable values
Data source binding
Widgets
Creating a blog site
Creating a document
Post a blog entry
Snippet and chunk basics
Generating output
Using a custom form for the Post a Blog ! page
HTML for the custom blog form
Steps to create a chunk
Using a chunk as a form template
Checking the Post a Blog ! page
Rich text editor for the blog content
Creating the template variable
Chunk and template variable
NewsPublisher and the Rtcontent field
Summary
5. Authentication and Authorization
Create web users
Other user properties
Add the login snippet
Document group for friends
Restricting access for a document
User group: Document group
User: User group
Post moderation
Creating a role
Creating a Manager user
Checking the new role
User registration
Showing a signup form
Joining a default group
Link the signup form in the log in snippet
Snippets and authorization
NewsPublisher and authentication
Summary
6. Content Aggregation
Ditto
More flexibility with parameters
Aggregated data in a template
Theming MODx—chunks and placeholders
Introducing tagging
Creating a template variable to hold the category
Assigning documents to a category
XML formats
Machine-readable formats and readers
Readers
Formats
Ditto and XML formats
Creating RSS views for each category
Filtering
Multiple clauses
Extenders
Summary
7. Creating Lists
Menu details in document properties
Authentication and authorization
Getting to know WayFinder
Theming
Creating a simple menu
Nested menus
Changing the name in the menu
Doc Manager
Removing pages from the menu
More theming using chunks
Breadcrumb navigation
Multiple calls
Summary
8. Snippets
Working of snippets
Finding snippets
Learning about snippets
Jot with the minimal configuration
Snippet parameters
Placeholders
Using non-bundled snippets
Installing a snippet
Downloading and extracting a snippet
Adding a snippet
Copying required files
Using the snippet
Snippet without dependent files
Snippeting skills
Summary
9. PHx
PHx in action
Installing PHx
Adding Family and Friends documents
The PHx notation
Simple usage
Conditional statements
Usage with the PHx placeholder
Multiple conditions
Summary
10. Simple Recipes
Forums
Installing SMF
Installing the SMF module
Image gallery
Emailing from forms
User profiles
Installing WebLoginPE
Edit profile
List users and view profile
Link to edit profile
Similar posts
Summary
11. Creating Snippets
Learning to create a snippet
Returning an output
Returning placeholders
Processing a chunk
Using parameters
MODx API
DBAPI
$MODx->db->select
$MODx->db->getRecordCount
$MODx->db->makeArray
Fortunes
Creating the table
Code for fortunes
Testing the snippet
Chunks, placeholders, and parameters
Using files
Summary
12. SEO, Deployment, and Security
SEO
Search engine-friendly URLs
Meta tags and keywords
Site map
XHTML Strict
Other SEO tweaks
Using CSS to control the layout
Content first
Hidden text
Descriptive text
Tracking
Inbound links
Quality content
Deployment
Filesystem
FTP
SFTP
WebDAV
Database
Exporting
Importing
Configuration file
Configurations
Security
File permissions
Installer
Writable configuration file
Captcha
mod_security
Unused files
Manager configurations
User tab
File Manager tab
Summary
13. Plug-ins and Modules
Plug-ins and events
Using an existing plug-in
Configuration
System events
Exploring other plug-ins
Using custom plug-ins
Learning about the plug-in
Creating plug-ins
Event-triggering snippets
Modules
Using modules
Creating a module
Executing a module
Module's Manager interface
Dependent plug-ins
Learning to use custom modules
Summary
Index
MODx Web Development
Antano Solar John
MODx Web Development
Copyright © 2009 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, Packt Publishing, nor its dealers or 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 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 published: March 2009
Production Reference: 1230309
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847194-90-9
www.packtpub.com
Cover Image by Nilesh Mohite (<[email protected]>)
Credits
Author
Antano Solar John
Reviewers
Shane Sponagle
Susan Ottwell
Acquisition Editor
Viraj Joshi
Development Editors
Sarah Cullington
Siddharth Mangarole
Technical Editor
Mithun Sehgal
Editorial Team Leader
Abhijeet Deobhakta
Project Coordinator
Leena Purkait
Indexer
Rekha Nair
Proofreader
Chris Smith
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Antano Solar is a techie to the core—a tech evangelist who is passionate about using technology to revolutionize the learning experience!
Antano has contributed to the open source community in terms of documentation, code, and support, with a variety of platforms based on languages such as PHP, Perl, Lisp, Python, and Ruby.
He loves to share his tech excitement with fellow techies and non-techies, and does so through publishing papers, books, and delivering seminars at colleges, universities such as the IIT, and corporate tech events.
He has published a paper on enhancing wireless networks in an IEEE Journal. His paper on an engine helping machines understand objectives by meta-modelling, using Neuro Linguistic Programming principles and Deep Structure, is considered a landmark.
An avid hacker, Antano has won two Yahoo hack day awards. He recently won the award for developing a Hybrid Search Engine from scratch in 24 hours that uses Machine Intelligence and Social Intelligence to identify, search, and present the information in the required format.
Professionally, Antano, until recently, has been a Consultant and a Trainer providing IT solutions and sessions on VoIP, Networks and Software Plaforms, and Languages. He is currently the Chief Technology Officer at NuVeda Learning. In his current role, he is responsible for the development and deployment of Learning Management Systems that are being used by large MNCs globally. He also plays the role of a Chief Architect in the research and development of technologies related to the understanding and measuring of Learning. He is excited by the challenges of using complex technologies such as Artificial Intelligence and Natural Language Processing.
Occasionally, when Antano needs to take a Tech
break, he likes to train and tell stories!
To those who prepared me:
My Mom and Dad—for all the hope, faith, love, and wise counsel.
And to those who made it happen:
The Packt team—especially Leena and Sarah—the reviewers, and the MODx community for an awesome open source development platform.
About the Reviewers
Shane Sponagle has over 10 years of experience in developing web-based applications. He is currently a senior partner at S/2M2 Design, and has worked on projects ranging from simple web sites to multi-level data-driven applications. Shane is an active member of the MODx community where he enjoys learning about all the interesting ways people are using MODx. He looks forward to collaborating on future publications.
Susan is a self-taught grandmother of eight. She first became interested in computers, both hardware and programming, more than 40 years ago, but got her first computer only a year before the arrival of her first grandchild. She spent a number of years working both independently and as a shop technician building and repairing PCs, from Connecticut to Miami to Israel, while learning various programming and database languages from x86 assembly to dBase to VB to perl in her spare time. For a time, she taught C++ for an online gaming service's online university
.
Her PHP studies began over eight years ago, and have been conducted solely with the assets garnered from the Internet. She discovered MODx when it was still a set of modifications to Etomite, found that it suited her needs, and when MODx forked into its own CMS/CMF system, decided to stick with it, learn it thoroughly, and contribute what she could.
Susan lives quietly, except for a very loud canary named Winston, in a Negev desert community in Israel, the home of PHP. She divides her time between hiking and photography in the desert hills and canyons, quilt making and knitting, and working with MODx on her iBook g4.
I owe everything I've accomplished in the last 15 years to my father and my first husband for telling me I'd never be able to do it, computers weren't of any use, and it's not for girls anyway. They triggered my stubborn streak, and made me determined to do this in spite of them! Then I am indebted to the giants of teaching: Jeff Duntemann, Tom Swan, and especially Gary Cornell, for all of their wonderful books. Certain web sites have become indispensable, among them Zend, O'Reilly's OnLamp, and A List Apart. And finally, perhaps most importantly, I owe Ryan Thrash, Raymond Irving, and Jason Coward for giving me MODx to play with in the first place, and now the rest of the MODx team, whom I only know by their MODx Forum handles. They're way above my head, but they give me something to work towards.
Preface
This book teaches you how to use MODx for creating powerful dynamic web sites, even without the knowledge of a programming language as a prerequisite. It leads the reader step by step in a logical pattern to build a complete web site. Each chapter covers certain concepts with simple examples. All the examples if you follow along, aggregate to a self-created web site. Towards the end, it has a chapter dedicated to the serious programmers who would like to extend what they can do with MODx.
This book can also be used as a reference or to relearn the particular concepts that have been discussed in each chapter. It has illustrative examples, wherever necessary, to make sure it is friendly. It has a mix of simple demonstrations and in-depth concepts that will interest both the casual and the serious reader.
What this book covers
Chapter 1: In this chapter, you will learn the general concepts of web development, and also learn why MODx as a tool is a good choice to develop your web site.
Chapter 2: In this chapter, you will learn how to set up a working platform for developing web sites with MODx, which includes the installation and configuration of the prerequisites such as Apache, PHP, and MySQL.
Chapter 3: In this chapter, you will learn about documents and containers, and how every page that is displayed gets its content from a document. You will also learn to create, edit, and manipulate documents, and manage their configurations, and we will explain the TinyMCE editor.
Chapter 4: In this chapter, you will learn how to create/add templates. We will also take a look at template variables and document-specific variables, and briefly discuss snippets and chunks.
Chapter 5: In this chapter, you will learn how to modify the site to have a signup form and login form. We will also learn how to enable blogs to be posted only by friends.
Chapter 6: In this chapter, you will learn one very useful snippet called Ditto. You will see how to create aggregation and feeds, and how to create feeds for separate categories. You will also learn about tagging, and how to tag documents and use them in MODx.
Chapter 7: In this chapter, you will learn how to use the snippet [[WayFinder]] to create lists of documents. We will also see the usage of parameters in WayFinder to make list creation flexible.
Chapter 8: In this chapter, you will learn how to use the hundreds of snippets available in detail. You will also learn how to search for the snippets that don't come packaged with MODx and how to use them.
Chapter 9: In this chapter, you will learn how to format the values in template variables. You will also learn how to make conditions based on the values of template variables, and accordingly present a different output either from the HTML in the expression or from a chunk or snippet.
Chapter 10: 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, an image gallery, or forms that can send a mail, create web user profiles, and identify similar posts for blogs.
Chapter 11: In this chapter, you will learn how to create snippets, the different ways of displaying their output, and how to implement them. You will also learn to use the available MODx APIs and why you should use them.
Chapter 12: In this chapter, we will discuss how to make the site optimized for search engines. We will also discuss clean URLs, meta tags, sitemaps, and other tweaks.
Chapter 13: Finally, in this chapter, you will learn about plug-ins and modules including the ones that we will use in our application. The chapter will also cover events and plug-in configuration.
What you need for this book
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.
Who this book is for
This book is ideal for those who want to learn to use MODx. Both beginners and experienced web developers will benefit from this comprehensive guide to MODx.
Conventions
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: "You have already seen an example of document-specific template variables when you