Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

concrete5 Cookbook
concrete5 Cookbook
concrete5 Cookbook
Ebook968 pages2 hours

concrete5 Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

The Cookbook-style recipes allow you to go both directly to your topic of interest or follow topics throughout a chapter to gain in-depth knowledge. This practical Cookbook will cater to the needs of both intermediate and advanced concrete5 developers.This book is geared towards intermediate to advanced PHP developers who would like to learn more about the concrete5 content management system. Developers already familiar with concrete5 will learn new time-saving tricks and will find the book to be a great reference tool.
LanguageEnglish
Release dateJul 26, 2013
ISBN9781782164555
concrete5 Cookbook

Related to concrete5 Cookbook

Related ebooks

Internet & Web For You

View More

Related articles

Reviews for concrete5 Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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

    Enjoying the preview?
    Page 1 of 1