You are previewing concrete5 Cookbook.
O'Reilly logo
concrete5 Cookbook

Book Description

Over 140 recipes to help you develop websites using the concrete5 content management system

  • Recipes for developing websites with concrete5, a popular open source content management system

  • A useful guide for concrete5 novices and experts alike

  • Contains blueprints of selected projects explained extensively with a top-to-bottom approach

In Detail

concrete5 is an increasingly popular open source content management system because of its incredible and easy-to-use interface. But, it also comes complete with a robust PHP framework, allowing web developers to create custom websites and applications with ease.

"concrete5 Cookbook" is a practical collection of solutions to tasks that both novice and experienced concrete5 developers face on a regular basis. Readers will learn multiple subjects, including full blueprints for developing an event calendar add-on and an image gallery block. Developers new to concrete5 will quickly learn how to customize concrete5 to their needs, and seasoned pros will find it an excellent quick reference for performing specific tasks.

"concrete5 Cookbook" will transform ordinary PHP developers into concrete5 experts capable of bending concrete5 to their will and unleashing the true power of this up-and-coming content management system. Throughout the course of over 140 recipes and 3 bonus project blueprint chapters, PHP developers will learn how to create custom blocks and dashboard interfaces as well as programmatically work with pages, files, users, permissions, and more. Discover the built-in Active Record support that makes working with databases simple and maintainable. Readers will also learn how to take advantage of the numerous helper classes included in concrete5, and will dive deep into the concrete5 MVC framework to create powerful custom websites and applications. Tie together all of the concepts learned in the recipes with 3 bonus chapters featuring complete blueprints to create a calendar add-on, an image gallery block type, and tips on how to sell your themes and add-ons for money!

"concrete5 Cookbook" is a complete collection of recipes to solve the most common (and some not-so-common) tasks that concrete5 developers will face on a regular basis.

Table of Contents

  1. concrete5 Cookbook
    1. Table of Contents
    2. concrete5 Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. 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
    8. 1. Pages and Page Types
      1. Introduction
        1. A note about the code in this chapter
      2. Create a custom debugging function
      3. Getting the current Page object
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Getting a Page object by its ID
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Getting a Page object by its path
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Getting a page type by its ID
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Getting a page type by its handle
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Getting a page type's ID
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Getting a page type's name
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Getting a page type's handle
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Getting the icon for a page type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      12. Getting a list of pages that belong to a page type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Creating a page type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      14. Updating a page type
        1. How to do it...
        2. How it works...
        3. See also
      15. Deleting a page type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Creating a page type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      17. Updating an existing page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      18. Setting page attributes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      19. Getting a page attribute
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      20. Getting a page's ID
        1. Getting ready
        2. How to do it...
        3. See also
      21. Getting a page's path
        1. How to do it...
        2. See also
      22. Getting a page's handle
        1. How to do it...
        2. See also
      23. Getting a page's name
        1. How to do it...
        2. See also
      24. Getting a page's description
        1. Getting ready
        2. How to do it...
        3. See also
      25. Getting a page's page type ID
        1. How to do it...
        2. See also
      26. Getting a page's page type handle
        1. How to do it...
        2. See also
      27. Getting a page's theme object
        1. How to do it...
        2. See also
      28. Getting the children below a page
        1. How to do it...
        2. How it works...
      29. Moving a page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      30. Deleting a page (and its children)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      31. Getting a list of pages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      32. Adding a page selector field to a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    9. 2. Working with Blocks
      1. Introduction
      2. Creating a custom block type
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Using block controller callback functions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Sending variables from the controller to the view
        1. Getting ready
        2. How to do it...
        3. See also
      5. Adding items to the page header and footer from the block controller
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Creating custom block templates
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      7. Including JavaScript in block forms
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Including JavaScript in the block view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Including CSS in the block view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Loading a block type by its handle
        1. Getting ready
        2. How to do it...
        3. How it works...
      11. Adding a block to a page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Getting the blocks from an area
        1. Getting ready
        2. How to do it...
        3. How it works...
    10. 3. Files and File Sets
      1. Introduction
        1. A note about the code in this chapter
      2. Loading a file by its ID
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Getting a file's path
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Getting a list of files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Uploading a file to the file manager
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Loading a file set by its ID
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Adding a file to a file set
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Removing a file from a file set
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Checking if a file is part of a file set
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Getting all of the files in a file set
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Duplicating a file
        1. Getting ready
        2. How to do it...
        3. How it works...
      12. Deleting a file
        1. Getting ready
        2. How to do it...
        3. How it works...
      13. Reindexing a file's search attributes
        1. Getting ready
        2. How to do it...
        3. How it works...
      14. Setting passwords on file objects
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      15. Setting permissions on files
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      16. Getting the download URL for a file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Getting the download statistics for a file
        1. Getting ready
        2. How to do it...
        3. How it works...
      18. Adding a file picker to a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    11. 4. Using the Core Helpers
      1. Introduction
        1. A note about the code in this chapter
      2. Loading a helper class
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Using the Date helper
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Using the Encryption helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Loading an RSS feed with the Feed helper
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Managing files and directories with the File helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Creating custom forms with the Form helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Including a WYSIWYG editor on a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Generating HTML code with the HTML helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Generating and caching thumbnails with the Image helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Encoding and decoding JSON with the JSON helper
        1. How to do it...
        2. How it works...
        3. See also
      12. Sending e-mails with the Mail helper
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      13. Determining the MIME type of a file extension using the MIME helper
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      14. Getting page URLs and breadcrumbs with the Navigation helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Working with strings using the Text helper
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      16. Generating URLs with the URL helper
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      17. Validating input data using the Validation helpers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      18. Preventing spam using the Captcha helper
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      19. Getting a list of countries
        1. How to do it...
        2. How it works...
        3. See also
      20. Getting a list of states and provinces
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      21. Showing a color picker on a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      22. Showing a date/time selector on a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      23. Showing a rating widget on a form
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      24. Using the banned words list
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      25. Reading and writing to the system cache
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      26. Writing to the debug log
        1. How to do it...
      27. Reading and writing to the configuration registry
        1. How to do it...
        2. How it works...
    12. 5. Working with Databases and Models
      1. Introduction
        1. Configuring database credentials
        2. How to do it...
        3. How it works...
      2. Loading the database object
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Retrieving data from the database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Writing data to the database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Guarding against SQL injections using prepared statements
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Creating a custom model class
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Reading from the database with active record
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Writing to the database with active record
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Updating a database record with active record
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Searching the database using active record
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Deleting objects using active record and model classes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Defining relationships with active record
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    13. 6. Creating CRUD Interfaces
      1. Introduction
        1. A note about the data in this chapter
      2. Creating controller files for single pages on the dashboard
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Creating view files for single pages on the dashboard
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Adding single pages to the dashboard
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Creating a form to create items
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Saving data to the database from a controller
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Creating a view to display a list of database items
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Adding editing capabilities to create a form
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Creating a delete action
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    14. 7. Working with Users and Permissions
      1. Introduction
      2. Checking if the current user is logged in
        1. How to do it...
        2. How it works...
      3. Getting the currently logged-in user
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Loading a user by its ID
        1. How to do it...
        2. How it works...
        3. See also
      5. Loading a user by its username
        1. How to do it...
        2. How it works...
        3. See also
      6. Getting a user's info
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Setting a user's attributes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Retrieving a user's attributes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Loading a group by its ID
        1. How to do it...
        2. How it works...
        3. See also
      10. Loading a group by its name
        1. How to do it...
        2. How it works...
        3. See also
      11. Adding a user to a group
        1. How to do it...
        2. How it works...
        3. See also
      12. Getting all of the users from a group
        1. How to do it...
        2. How it works...
        3. See also
      13. Checking if a user is a member of a group
        1. How to do it...
        2. How it works...
        3. See also
      14. Removing a user from a group
        1. How to do it...
        2. How it works...
        3. See also...
      15. Logging out a user
        1. How to do it...
        2. How it works...
        3. See also
      16. Deleting a user
        1. How to do it...
        2. How it works...
        3. See also
      17. Getting the permission object
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      18. Checking if a user can read a page
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      19. Checking if a user can edit a page
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      20. Checking a user's file permissions
        1. How to do it...
        2. How it works...
        3. There's more...
    15. 8. Working with Themes and Add-ons
      1. Introduction
      2. Creating a custom theme
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Including the concrete5 required scripts and styles
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Defining editable content areas
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Creating page type templates
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Using elements for repeated portions of HTML
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Customizing system pages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Creating a custom add-on package
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Using the package controller to execute custom code
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    16. 9. System Events and Advanced Configuration
      1. Introduction
        1. About the code in this chapter
      2. Declaring advanced configuration variables
        1. How to do it...
        2. How it works...
      3. Enabling events in concrete5
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Listening to system events
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Passing parameters to event handlers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Defining a page type event
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Sending an e-mail when a user creates an account
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Sending an e-mail when a file has been uploaded
        1. How to do it...
        2. How it works...
        3. See also
      9. Creating a custom scheduled job
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Making your add-on translation ready
        1. How to do it...
        2. How it works...
      11. Rebranding concrete5 as a white label CMS
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      12. Changing the dashboard background image
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    17. A. Blueprint – Creating an Image Gallery Add-on
      1. Before we begin...
      2. Creating the package controller
      3. Creating the block type
        1. The block's controller
        2. The database XML file
        3. The block type's view files
      4. Installing the block type with the package
        1. Installing the package in concrete5
        2. Creating a page for the gallery
      5. Giving life to the block
        1. Filling out the add and edit view files
        2. Creating the gallery view file
        3. Trying out the block
      6. Wrap-up
    18. B. Blueprint – Creating an Events Calendar Add-on
      1. Before we begin...
      2. Creating the package
        1. The package controller
        2. The package database XML file
        3. The model
        4. Single page controllers
        5. Single page views
        6. The event list block type
        7. The block's database XML file
        8. The block view files
      3. Installing the package
        1. Installing the package to the dashboard
      4. Creating the list single page
        1. Creating the list view
      5. Creating the add form single page
        1. The form view file
      6. Adding events to the database
      7. Adding a delete confirmation
      8. Creating the custom block type
      9. Adding the block to a page
      10. Wrapping up
    19. C. Submitting an Add-on Package to the concrete5 Marketplace
      1. The rules
      2. The process
        1. The Peer Review Board
        2. Selling your add-on
        3. Once the add-on is approved...
      3. Official resources
    20. Index