concrete5 Cookbook
By David Strack
()
About this ebook
Related to concrete5 Cookbook
Related ebooks
Windows Application Development Cookbook Rating: 0 out of 5 stars0 ratingsMicrosoft Dynamics NAV 7 Programming Cookbook Rating: 0 out of 5 stars0 ratingsElasticsearch 5.x Cookbook - Third Edition Rating: 0 out of 5 stars0 ratingsElasticSearch Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsYii 1.1 Application Development Cookbook Rating: 0 out of 5 stars0 ratingsjQuery Mobile Cookbook Rating: 0 out of 5 stars0 ratingsYii Application Development Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsMicrosoft Dynamics NAV 2009 Programming Cookbook Rating: 0 out of 5 stars0 ratingsElasticSearch Cookbook Rating: 5 out of 5 stars5/5MooTools 1.3 Cookbook Rating: 0 out of 5 stars0 ratingsWeb Development with Django Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsVisualforce Development Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsDart Cookbook Rating: 0 out of 5 stars0 ratingsSencha Touch Cookbook Rating: 0 out of 5 stars0 ratingsjQuery 2.0 Development Cookbook Rating: 0 out of 5 stars0 ratingsChronoForms 3.1 for Joomla! site Cookbook Rating: 0 out of 5 stars0 ratingsHTML5 Data and Services Cookbook Rating: 5 out of 5 stars5/5Visualforce Development Cookbook Rating: 0 out of 5 stars0 ratingsDotNetNuke 5.4 Cookbook Rating: 5 out of 5 stars5/5Ext JS 3.0 Cookbook Rating: 0 out of 5 stars0 ratingsGroovy 2 Cookbook Rating: 0 out of 5 stars0 ratingsAndroid Application Development Cookbook - Second Edition Rating: 5 out of 5 stars5/5CMS Made Simple Development Cookbook Rating: 0 out of 5 stars0 ratingsSQL Server 2012 with PowerShell V3 Cookbook Rating: 0 out of 5 stars0 ratingsApache OfBiz Cookbook Rating: 0 out of 5 stars0 ratingswxPython Application Development Cookbook Rating: 0 out of 5 stars0 ratingsDrupal 6 Theming Cookbook Rating: 0 out of 5 stars0 ratingsOdoo Development Cookbook Rating: 0 out of 5 stars0 ratingsWordPress 2.8 Themes Cookbook Rating: 0 out of 5 stars0 ratingsJIRA Development Cookbook - Third Edition Rating: 0 out of 5 stars0 ratings
Internet & Web For You
More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Introduction to Internet Scams and Fraud: Credit Card Theft, Work-At-Home Scams and Lottery Scams Rating: 4 out of 5 stars4/5Wireless Hacking 101 Rating: 4 out of 5 stars4/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Podcasting For Dummies Rating: 4 out of 5 stars4/5Cybersecurity For Dummies Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Learn HTML Programming in 7 Days: Ultimate Beginners Guide to Build and Design Your Own Website Rating: 4 out of 5 stars4/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsRemote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5The Internet Is Not What You Think It Is: A History, a Philosophy, a Warning Rating: 4 out of 5 stars4/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5200+ Ways to Protect Your Privacy: Simple Ways to Prevent Hacks and Protect Your Privacy--On and Offline Rating: 0 out of 5 stars0 ratingsHow To Make Money Blogging: How I Replaced My Day-Job With My Blog and How You Can Start A Blog Today Rating: 4 out of 5 stars4/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5Lying and Lie Detection: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsHow To Start A Podcast Rating: 4 out of 5 stars4/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratingsUltimate Guide for Being Anonymous: Hacking the Planet, #4 Rating: 5 out of 5 stars5/5The Cyber Attack Survival Manual: Tools for Surviving Everything from Identity Theft to the Digital Apocalypse Rating: 0 out of 5 stars0 ratings
Reviews for concrete5 Cookbook
0 ratings0 reviews
Book preview
concrete5 Cookbook - David Strack
Table of Contents
concrete5 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
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
Errata
Piracy
Questions
1. Pages and Page Types
Introduction
A note about the code in this chapter
Create a custom debugging function
Getting the current Page object
How to do it...
How it works...
There's more...
See also
Getting a Page object by its ID
Getting ready
How to do it...
How it works...
See also
Getting a Page object by its path
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a page type by its ID
Getting ready
How to do it...
How it works...
See also
Getting a page type by its handle
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a page type's ID
Getting ready
How to do it...
How it works...
See also
Getting a page type's name
Getting ready
How to do it...
How it works...
See also
Getting a page type's handle
Getting ready
How to do it...
How it works...
See also
Getting the icon for a page type
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a list of pages that belong to a page type
Getting ready
How to do it...
How it works...
See also
Creating a page type
Getting ready
How to do it...
How it works...
There's more...
See also
Updating a page type
How to do it...
How it works...
See also
Deleting a page type
Getting ready
How to do it...
How it works...
See also
Creating a page type
Getting ready
How to do it...
How it works...
There's more...
See also
Updating an existing page
Getting ready
How to do it...
How it works...
There's more...
See also
Setting page attributes
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a page attribute
Getting ready
How to do it...
How it works...
See also
Getting a page's ID
Getting ready
How to do it...
See also
Getting a page's path
How to do it...
See also
Getting a page's handle
How to do it...
See also
Getting a page's name
How to do it...
See also
Getting a page's description
Getting ready
How to do it...
See also
Getting a page's page type ID
How to do it...
See also
Getting a page's page type handle
How to do it...
See also
Getting a page's theme object
How to do it...
See also
Getting the children below a page
How to do it...
How it works...
Moving a page
Getting ready
How to do it...
How it works...
See also
Deleting a page (and its children)
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a list of pages
Getting ready
How to do it...
How it works...
There's more...
Adding a page selector field to a form
Getting ready
How to do it...
How it works...
There's more...
2. Working with Blocks
Introduction
Creating a custom block type
Getting ready
How to do it...
How it works...
See also
Using block controller callback functions
Getting ready
How to do it...
How it works...
There's more...
See also
Sending variables from the controller to the view
Getting ready
How to do it...
See also
Adding items to the page header and footer from the block controller
Getting ready
How to do it...
How it works...
See also
Creating custom block templates
Getting ready
How to do it...
There's more...
See also
Including JavaScript in block forms
Getting ready
How to do it...
How it works...
See also
Including JavaScript in the block view
Getting ready
How to do it...
How it works...
See also
Including CSS in the block view
Getting ready
How to do it...
How it works...
See also
Loading a block type by its handle
Getting ready
How to do it...
How it works...
Adding a block to a page
Getting ready
How to do it...
How it works...
See also
Getting the blocks from an area
Getting ready
How to do it...
How it works...
3. Files and File Sets
Introduction
A note about the code in this chapter
Loading a file by its ID
Getting ready
How to do it...
How it works...
Getting a file's path
Getting ready
How to do it...
How it works...
There's more...
See also
Getting a list of files
Getting ready
How to do it...
How it works...
There's more...
See also
Uploading a file to the file manager
Getting ready
How to do it...
How it works...
See also
Loading a file set by its ID
Getting ready
How to do it...
How it works...
There's more...
See also
Adding a file to a file set
Getting ready
How to do it...
How it works...
There's more...
See also
Removing a file from a file set
Getting ready
How to do it...
How it works...
See also
Checking if a file is part of a file set
Getting ready
How to do it...
How it works...
See also
Getting all of the files in a file set
Getting ready
How to do it...
How it works...
See also
Duplicating a file
Getting ready
How to do it...
How it works...
Deleting a file
Getting ready
How to do it...
How it works...
Reindexing a file's search attributes
Getting ready
How to do it...
How it works...
Setting passwords on file objects
Getting ready
How to do it...
How it works...
There's more...
See also
Setting permissions on files
Getting ready
How to do it...
There's more...
See also
Getting the download URL for a file
Getting ready
How to do it...
How it works...
See also
Getting the download statistics for a file
Getting ready
How to do it...
How it works...
Adding a file picker to a form
Getting ready
How to do it...
How it works...
There's more...
See also
4. Using the Core Helpers
Introduction
A note about the code in this chapter
Loading a helper class
How to do it...
How it works...
There's more...
Using the Date helper
Getting ready
How to do it...
How it works...
Using the Encryption helper
Getting ready
How to do it...
How it works...
See also
Loading an RSS feed with the Feed helper
How to do it...
How it works...
There's more...
Managing files and directories with the File helper
Getting ready
How to do it...
How it works...
There's more...
See also
Creating custom forms with the Form helper
Getting ready
How to do it...
How it works...
There's more...
See also
Including a WYSIWYG editor on a form
Getting ready
How to do it...
How it works...
See also
Generating HTML code with the HTML helper
Getting ready
How to do it...
How it works...
See also
Generating and caching thumbnails with the Image helper
Getting ready
How to do it...
How it works...
There's more...
See also
Encoding and decoding JSON with the JSON helper
How to do it...
How it works...
See also
Sending e-mails with the Mail helper
How to do it...
How it works...
There's more...
See also
Determining the MIME type of a file extension using the MIME helper
How to do it...
How it works...
There's more...
See also
Getting page URLs and breadcrumbs with the Navigation helper
Getting ready
How to do it...
How it works...
See also
Working with strings using the Text helper
How to do it...
How it works...
There's more...
See also
Generating URLs with the URL helper
How to do it...
How it works...
There's more...
See also
Validating input data using the Validation helpers
Getting ready
How to do it...
How it works...
There's more...
See also
Preventing spam using the Captcha helper
Getting ready
How to do it...
How it works...
See also
Getting a list of countries
How to do it...
How it works...
See also
Getting a list of states and provinces
How to do it...
How it works...
There's more...
See also
Showing a color picker on a form
Getting ready
How to do it...
How it works...
See also
Showing a date/time selector on a form
Getting ready
How to do it...
How it works...
There's more...
See also
Showing a rating widget on a form
How to do it...
How it works...
There's more...
See also
Using the banned words list
How to do it...
How it works...
There's more...
See also
Reading and writing to the system cache
Getting ready
How to do it...
How it works...
There's more...
See also
Writing to the debug log
How to do it...
Reading and writing to the configuration registry
How to do it...
How it works...
5. Working with Databases and Models
Introduction
Configuring database credentials
How to do it...
How it works...
Loading the database object
How to do it...
How it works...
There's more...
Retrieving data from the database
Getting ready
How to do it...
How it works...
There's more...
See also
Writing data to the database
Getting ready
How to do it...
How it works...
There's more...
Guarding against SQL injections using prepared statements
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a custom model class
Getting ready
How to do it...
How it works...
There's more...
See also
Reading from the database with active record
Getting ready
How to do it...
How it works...
See also
Writing to the database with active record
Getting ready
How to do it...
How it works...
See also
Updating a database record with active record
Getting ready
How to do it...
How it works...
See also
Searching the database using active record
Getting ready
How to do it...
How it works...
There's more...
See also
Deleting objects using active record and model classes
Getting ready
How to do it...
How it works...
See also
Defining relationships with active record
Getting ready
How to do it...
How it works...
There's more...
See also
6. Creating CRUD Interfaces
Introduction
A note about the data in this chapter
Creating controller files for single pages on the dashboard
Getting ready
How to do it...
How it works...
See also
Creating view files for single pages on the dashboard
Getting ready
How to do it...
How it works...
See also
Adding single pages to the dashboard
Getting ready
How to do it...
How it works...
See also
Creating a form to create items
Getting ready
How to do it...
How it works...
There's more...
See also
Saving data to the database from a controller
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a view to display a list of database items
Getting ready
How to do it...
How it works...
See also
Adding editing capabilities to create a form
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a delete action
Getting ready
How to do it...
How it works...
There's more...
See also
7. Working with Users and Permissions
Introduction
Checking if the current user is logged in
How to do it...
How it works...
Getting the currently logged-in user
Getting ready
How to do it...
How it works...
See also
Loading a user by its ID
How to do it...
How it works...
See also
Loading a user by its username
How to do it...
How it works...
See also
Getting a user's info
Getting ready
How to do it...
How it works...
See also
Setting a user's attributes
Getting ready
How to do it...
How it works...
See also
Retrieving a user's attributes
Getting ready
How to do it...
How it works...
There's more...
See also
Loading a group by its ID
How to do it...
How it works...
See also
Loading a group by its name
How to do it...
How it works...
See also
Adding a user to a group
How to do it...
How it works...
See also
Getting all of the users from a group
How to do it...
How it works...
See also
Checking if a user is a member of a group
How to do it...
How it works...
See also
Removing a user from a group
How to do it...
How it works...
See also...
Logging out a user
How to do it...
How it works...
See also
Deleting a user
How to do it...
How it works...
See also
Getting the permission object
How to do it...
How it works...
There's more...
See also
Checking if a user can read a page
How to do it...
How it works...
There's more...
See also
Checking if a user can edit a page
How to do it...
How it works...
There's more...
See also
Checking a user's file permissions
How to do it...
How it works...
There's more...
8. Working with Themes and Add-ons
Introduction
Creating a custom theme
Getting ready
How to do it...
How it works...
There's more...
See also
Including the concrete5 required scripts and styles
Getting ready
How to do it...
How it works...
There's more...
See also
Defining editable content areas
Getting ready
How to do it...
How it works...
There's more...
See also
Creating page type templates
Getting ready
How to do it...
How it works...
There's more...
See also
Using elements for repeated portions of HTML
Getting ready
How to do it...
How it works...
See also
Customizing system pages
Getting ready
How to do it...
How it works...
See also
Creating a custom add-on package
Getting ready
How to do it...
How it works...
There's more...
See also
Using the package controller to execute custom code
Getting ready
How to do it...
How it works...
See also
9. System Events and Advanced Configuration
Introduction
About the code in this chapter
Declaring advanced configuration variables
How to do it...
How it works...
Enabling events in concrete5
How to do it...
How it works...
There's more...
See also
Listening to system events
Getting ready
How to do it...
How it works...
See also
Passing parameters to event handlers
Getting ready
How to do it...
How it works...
See also
Defining a page type event
Getting ready
How to do it...
How it works...
There's more...
See also
Sending an e-mail when a user creates an account
Getting ready
How to do it...
How it works...
See also
Sending an e-mail when a file has been uploaded
How to do it...
How it works...
See also
Creating a custom scheduled job
Getting ready
How to do it...
How it works...
There's more...
Making your add-on translation ready
How to do it...
How it works...
Rebranding concrete5 as a white label CMS
Getting ready
How to do it...
How it works...
There's more...
See also
Changing the dashboard background image
Getting ready
How to do it...
How it works...
There's more...
See also
A. Blueprint – Creating an Image Gallery Add-on
Before we begin...
Creating the package controller
Creating the block type
The block's controller
The database XML file
The block type's view files
Installing the block type with the package
Installing the package in concrete5
Creating a page for the gallery
Giving life to the block
Filling out the add and edit view files
Creating the gallery view file
Trying out the block
Wrap-up
B. Blueprint – Creating an Events Calendar Add-on
Before we begin...
Creating the package
The package controller
The package database XML file
The model
Single page controllers
Single page views
The event list block type
The block's database XML file
The block view files
Installing the package
Installing the package to the dashboard
Creating the list single page
Creating the list view
Creating the add form single page
The form view file
Adding events to the database
Adding a delete confirmation
Creating the custom block type
Adding the block to a page
Wrapping up
C. Submitting an Add-on Package to the concrete5 Marketplace
The rules
The process
The Peer Review Board
Selling your add-on
Once the add-on is approved...
Official resources
Index
concrete5 Cookbook
concrete5 Cookbook
Copyright © 2013 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 published: July 2013
Production Reference: 1190713
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-454-8
www.packtpub.com
Cover Image by John M. Quick (<john.m.quick@gmail.com>)
Credits
Author
David Strack
Reviewers
Remo Laubacher
Werner Nindl
Sharon L. Rivera
James Shannon
Acquisition Editor
Joanne Fitzpatrick
Lead Technical Editor
Balaji Naidu
Technical Editors
Dipika Gaonkar
Dennis John
Athira Laji
Mrunmayee Patil
Sonali S. Vernekar
Project Coordinator
Shiksha Chaturvedi
Proofreader
Ting Baker
Indexer
Monica Ajmera Mehta
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
About the Author
David Strack has been a software engineer for over 10 years. With a strong background in HTML, PHP, and JavaScript, he has developed websites for dozens of companies, large and small. David currently works for a small startup in California creating energy analytics software. He lives in Milwaukee, Wisconsin, with his wife, Sarah, and their crazy dog, Brewski. David can