You are previewing CMS Made Simple Development Cookbook.
O'Reilly logo
CMS Made Simple Development Cookbook

Book Description

Overview of CMS Made Simple Development Cookbook

  • Build new modules and tags, and use the built-in capabilities of CMS Made Simple to their fullest

  • Provides complete examples as well as educational starting points for your own projects

  • Designed to give you an understanding of the entire system

  • Covers CMS Made Simple version 1.9x

  • Step-by-step “recipes” along with detailed explanations

  • In Detail

    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.

    A hands-on collection of recipes for extending CMS Made Simple, with detailed explanations – useful for beginners and experts alike!

    Table of Contents

    1. CMS Made Simple Development Cookbook
      1. CMS Made Simple Development Cookbook
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      7. 1. Understanding CMS Extensions
        1. Introduction
        2. Will a User-Defined Tag solve my problem?
          1. How to do it...
          2. How it works...
          3. See also
        3. Will a Tag Solve My Problem?
          1. How to do it...
          2. How it works...
          3. See also
        4. Will a Module solve my problem?
          1. How to do it...
          2. How it works...
          3. See also
        5. Create a "Hello World" User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Caching
          5. See also
        6. Create a "Hello World" Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Caching
            2. Tag Names and Namespaces
          5. See also
        7. Create a "Hello World" Module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Using CMS in Debug Mode
          1. How to do it...
          2. How it works...
          3. See also
      8. 2. Programming with Smarty and Core Modules
        1. Introduction
        2. Using Smarty to create a color set in your stylesheet
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using Smarty to do the math in your stylesheet
          1. Getting ready
          2. How to do it...
            1. How it works...
            2. There's more...
            3. See also
          3. Renaming the "Extra Page Attributes" in the CMS Admin
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. What else can I rename?
            5. See also
          4. Creating a personnel directory using Menu Manage
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. Using other page attributes
              2. Why use a naming convention for images?
            5. See also
          5. Creating a basic Google Sitemap with Menu Manager and mod_rewrite
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. The changefreq and priority attributes
              2. What if my site is not UTF-8?
            5. See also
          6. Embedding JavaScript in your template without causing Smarty to throw a fit
            1. Getting ready
            2. How to do it...
            3. How it works...
              1. An alternative approach
              2. Using Smarty Variables in your JavaScript
          7. Using Smarty loops to generate similar stylesheet constructs
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          8. Displaying a block only for the Home page
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. More complex comparisons
            5. See also
          9. Using Smarty "Capture" and conditionals to hide empty content blocks
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          10. Seeing what Smarty variables are available to your template
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. Risky recursion
            5. See also
      9. 3. Getting the Most out of Tags and User-Defined Tags
        1. Introduction
        2. Displaying the User's IP address from a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Using the CmsObject and the current content object in a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Getting attributes using page_attr
            2. Old code and the use of globals
        4. Making a variable available to Smarty
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Displaying the number of pages in the CMS using a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Using URL parameters safely in a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Using Smarty values as inputs in a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Displaying stock prices from Yahoo with a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Understanding Yahoo's stock quote URL format
          5. See also
        9. Displaying a translation of the current page using Babelfish with a User-Defined Tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Posting an article to the News Module when the Admin adds a new Group
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Reversing a string in two ways using a Smarty Modifier
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Adding registered trademark symbols to a name automatically
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Handling more than just content blocks
            2. Pre-compile filters
          5. See also
      10. 4. Getting Started with Modules
        1. Introduction
        2. Creating the file structure for a module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Other files in your module directory
            2. Directly accessed scripts
          5. See also
        3. Creating a new module stub using the Skeleton module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Creating a new module stub using the ModuleMaker module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Breaking a module into multiple files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Making a module localizable
          1. Getting ready
          2. How to do it...
            1. How it works...
            2. There's more...
              1. Localization of modules without Subversion
            3. See also
          3. Using Smarty variables and templates with a module
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. $this->smarty versus $smarty
            5. See also
          4. Calling methods on other modules and specifying module dependencies
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. Dependencies and ModuleManager
              2. Error checking
            5. See also
      11. 5. Using the Database API
        1. Introduction
        2. Creating a database table when a module gets installed
          1. How to do it...
          2. How it works...
          3. There's more...
            1. ADOdb or ADOdb-lite?
          4. See also
        3. Creating a database index when creating a table
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Making a database query from a module
          1. How to do it...
          2. How it works...
          3. See also
        5. Creating and using a database sequence
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Deciding between Sequences and Auto-increment
          4. See also
        6. Altering a database table when a module gets upgraded
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Cleaning up when a module is uninstalled
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      12. 6. Using the Module Form API
        1. Introduction
        2. Creating a basic form in a module
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Restricting and sanitizing parameters to a module
          1. How to do it...
          2. How it works...
          3. There's more...
            1. CLEAN_STRING and entity encoding
          4. See also
        4. Using debug_display or error_log to see what parameters your module is receiving
          1. How to do it...
            1. How it works...
            2. See also
          2. Making your module display its output without disrupting the rest of the page
            1. How to do it...
            2. How it works...
            3. There's more...
            4. See also
          3. Embedding your module output in a different page after a form submission
            1. How to do it...
            2. How it works...
            3. There's more...
              1. Modules and multi-page forms
            4. See also
          4. Creating checkboxes that always submit a value
            1. How to do it...
            2. How it works...
            3. There's more...
            4. See also
      13. 7. Your Module and the Community
        1. Introduction
        2. Creating an account on the CMS Made Simple Developer's Forge
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Adding your module to the Forge
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Creating your Subversion Repository
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Subversion Documentation
          5. See also
        5. Using Subversion while developing your module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More useful Subversion commands
            2. Viewing and reverting to earlier revisions
          5. See also
        6. Publishing a module release
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Creating your Git repository
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Using Git while developing your module
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Handling conflicts in Git
          5. See also
        9. Deciding on Git versus Subversion
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      14. 8. Creating Useful Admin Panels
        1. Introduction
        2. Creating an admin panel for your module
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Creating multiple tabs for your admin module
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Creating and enforcing new permissions for your module's administration
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Displaying a page in the CMS Admin without the surrounding theme
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Using the "showtemplate" parameter
          4. See also
        6. Writing a line to the CMS Admin Log
          1. How to do it...
          2. How it works...
          3. See also
        7. Displaying a message after installation
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Creating an admin-side input element from your module using a ContentModule block
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Hiding your module from Administrators who don't have permission to use it
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Creating a module-specific preference and admin panel to set it
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Displaying an alert in the CMS Admin from a module
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      15. 9. Using Events
        1. Introduction
        2. Attaching a User-Defined Tag to an event
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Finding what parameters an event passes using a User Defined Tag
          1. How to do it...
            1. How it works...
            2. See also
          2. Generating an Event from a module
            1. How to do it...
            2. How it works...
            3. There's more...
              1. Event help-text conventions
            4. See also
          3. Handling an Event with a module
            1. How to do it...
              1. How it works...
              2. There's more...
              3. See also
            2. Use an event to send an e-mail when an Administrator Account is added or deleted
              1. How to do it...
              2. How it works...
              3. There's more...
                1. PreSave versus PostSave events
              4. See also
      16. 10. Advanced Module Tricks and SEO
        1. Introduction
        2. Overriding Module strings or layout
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Why not change modules directly?
          4. See also
        3. Making your module's data available to CMS Site Search
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Outputting a downloadable CSV file from your module
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Setting special diagnostic messages for debug mode
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Using Pretty URLs in your module
          1. How to do it...
            1. How it works...
            2. See also
          2. Custom URLs for module records in CMS Made Simple version 1.9+
            1. How to do it...
            2. How it works...
            3. There's more...
            4. See also