Book Image

CMS Made Simple Development Cookbook

Book Image

CMS Made Simple Development Cookbook

Overview of this book

CMS Made Simple has great capabilities “out of the box,” but one of its great strengths is the ease of extending those capabilities. You can add a surprising amount of functionality just by customizing the core modules, but once you learn to write your own tags and modules, your ability to add features is virtually limitless.CMS Made Simple Development Cookbook will show you how to use custom PHP code to extend the power and features of CMS Made Simple, and make it do exactly what you want. This easy to use guide contains clear recipes that introduce the key concepts behind each approach to extending the CMS, while also providing examples of solutions to real-world problems.You will learn the differences between the various kinds of tags and modules in the CMS Made Simple environment, and to which purposes each is best fit. Each technology is then explored in detail with a series of practical recipes and examples.You will not only learn the basics of creating tags and modules, but you will explore the underlying APIs that you will use to solve real-world website problems. You will become proficient with the database and form APIs, so that the code you write is portable and maintainable. You'll learn to localize your code and use templates to add its flexibility. You'll master the safe handling of parameters and the creation of secure code. You’ll be familiar with the CMS Made Simple Developer's Forge, and how you can use it in conjunction with revision control as a community-focused code management system, complete with web-based bug tracking and feature requests. You will learn to code complex interactions between modules, both directly and via the creation and handling of events. You will gain exposure to an array of advanced tips and tricks, along with commentary from the distilled experience of someone who has written dozens of modules. The CMS Made Simple Developer's Cookbook offers an amazing wealth of knowledge in approachable, bite-sized recipes. Whether you're new to the CMS or an old hand, you're sure to find valuable tips and information that will have you creating a richer CMS.
Table of Contents (16 chapters)
CMS Made Simple Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Preface

The CMS Made Simple Development Cookbook gets you started building feature-rich sites quickly, regardless of your experience level. It contains clear recipes that introduce the key concepts behind each approach to extending the CMS, while also providing examples of solutions to real-world problems.

CMS Made Simple has great capabilities "out of the box," but one of its great strengths is the ease of extending those capabilities. You can add a surprising amount of functionality just by customizing the core modules, but once you learn to write your own tags and modules, your ability to add features is virtually limitless.

What this book covers

Chapter 1, Understanding CMS Extensions, introduces the key differences between tags, user-defined tags, and modules, and teaches you to determine which is optimal for any given purpose. This chapter focuses on understanding the different approaches and deciding which to use to solve any particular problem.

Chapter 2, Programming with Smarty and Core Modules, demonstrates the use of Smarty and template logic to achieve complex functionality without installing anything beyond the CMS Made Simple core. You'll see how to do things you never thought were possible - all without writing any PHP code.

Chapter 3, Getting the Most out of Tags and User-Defined Tags, gives examples of Tags and User-Defined Tags, and shows how to create tags to handle such varied tasks as setting Smarty variables, filtering content, interfacing with modules, and interacting with web services. This chapter also includes information on some key CMS components, security pointers, and more.

Chapter 4, Getting Started with Modules, shows how you can use tools to jump start the module writing process, and demonstrates how to write fully-localizable modules in a maintainable and memory-efficient fashion. This chapter will give you a good basic understanding of how modules are organized and how they work.

Chapter 5, Using the Database API, shows how to interact with the underlying database using the Database API for safe, platform-independent access. This also includes discussion of updating database tables during module upgrades, getting better performance from your database with indexes, and generating unique IDs.

Chapter 6, Using the Module Form API, demonstrates how to render and process complex forms and user interfaces with the Form API. This chapter includes an example of a complete web form-handling application, along with tricks for debugging forms and sanitizing parameters.

Chapter 7, Your Module and the Community, gets you fully involved in the CMS Made Simple community. This chapter gives you a brief tour of the Developer's Forge, shows you how to use shared source-control repositories, and explains how to publish your modules.

Chapter 8, Creating Useful Admin Panels, teaches you how to build tabbed admin-side panels so site administrators can manage and configure your module. This chapter also covers custom content block types, admin permissions, setting preferences, and displaying messages to site administrators.

Chapter 9, Using Events, demonstrates handling events with User-Defined Tags, and both triggering and handling events with modules. This chapter explains how you can use events to enable complex interactions with tags and modules.

Chapter 10, Advanced Module Tricks and SEO, explains how to implement SEO-friendly URLs, making your module's content available to site search, override module strings, and export module data to desktop applications.

What you need for this book

The minimal requirements for this book would be a web server with PHP 5.2 (5.2.18 or later preferred) and a database server (MySQL version 4.1 or later, or PostgreSQL). Any web server should work, but one recipe uses Apache's mod_rewrite, so to test that one, an Apache-compatible web server would be needed. We will also need a modern web browser (IE 8+, Firefox 3.x+, Safari, or Chrome), some kind of text editor, and, of course, CMS Made Simple version 1.9.x.

CMS Made Simple's full requirements can be found at http://wiki.cmsmadesimple.org/index.php/User_Handbook/Installation/Requirements and the code can be downloaded at http://dev.cmsmadesimple.org/project/files/6.

Who this book is for

If you are a CMS Made Simple user wanting to expand your skill set, or a programmer who wants to develop for CMS Made Simple, this book is for you. You will need working knowledge of PHP, HTML, and SQL. Some experience with CMS Made Simple is recommended.

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: "Custom URLs are accomplished entirely in your module's SetParameters() method, by creating new CmsRoute objects, and registering them with the CMS."

A block of code is set as follows:

<?php
class Monsters extends CMSModule
{
function GetName()
{
return 'Monsters';
}
function GetVersion()
{
return '0.1';
}
}
?>

Any command-line input or output is written as follows:

mkdir MyModule/lang/ext

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 XML button next to your module, and save the exported file in some easily accessible directory".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

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 , 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 .

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.

Customer support

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

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.

Errata

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

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 with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.