cbdw2014 - building contentbox modules
DESCRIPTION
A key to building extensible and well-organized apps is to think modularly. Not only does this provide a nice separation of concerns in your code, but it also provides high portability and can enable community collaboration. In this session we will discuss the theory behind ContentBox Modules, how and when to use them, why they are important, and how they can change how you architect your applications. We will also look at the ins about outs of creating modules and discuss some of the challenges associated with building them. So if you are new to ColdBox/ContentBox Modules or if you have already started down the path of modular architecture, this session if for youTRANSCRIPT
![Page 1: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/1.jpg)
ContentBoxModular CMS
Time to release your content from it’s box!
![Page 2: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/2.jpg)
Who am I?Luis Majano - Computer Engineer
Born in El Salvador ------------------>
President of Ortus Solutions
Manager of the IECFUG (www.iecfug.com)
Creator of ColdBox, MockBox, LogBox, CacheBox, WireBox, ContentBox, or anything Box!
Documentation Weirdo!
@lmajano, @ortussolutions
![Page 3: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/3.jpg)
Agenda
ContentBox Overview + Technology
ContentBox Modularity
Deployment + Scalability
Features
Build Stuff
![Page 4: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/4.jpg)
ContentBox Modular CMS
Modular CMS Powered by ColdBox OO Content Model Powered by ORM Built to scale, cluster and deploy securely Public release August 2012 Professional Open Source
www.gocontentbox.org
![Page 5: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/5.jpg)
Why Modules?
![Page 6: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/6.jpg)
ContentBox Modularity
ANYColdBox MVC
Application
ContentBox Admin
ContentBox UI
ContentBox Core
Forum eCommerce
Custom App
Custom Security Views Model
Events
ColdBox Modules
Security
![Page 7: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/7.jpg)
Modular Architecture
ContentBox Admin
ContentBox UI
ContentBox Core
Forum eCommerce
Custom Module
Flex/AirRemote
RESTful QA Module
Google Analytics
![Page 8: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/8.jpg)
Modular Deployment
![Page 9: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/9.jpg)
Traditional Deployment
Monolithic APP, ADMIN, TOOLS,
API
DMZ
Database
![Page 10: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/10.jpg)
Modular Segregated Deployment
ContentBox UI
DMZ
Database
ContentBox Admin
ContentBox Core
ContentBox Core
Reportin Security SAP
REST
![Page 11: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/11.jpg)
ContentBox Modules
Extended ColdBox Modules Managed by ContentBox Admin
Activated/Deactivated Installed/Uninstalled
Extend ContentBox or ColdBox Application ContentBox is a collection of modules wiki.coldbox.org/wiki/Modules.cfm
![Page 12: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/12.jpg)
ContentBox Modules
![Page 13: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/13.jpg)
FeaturesContentBox menu contributions Custom events
ContentBox admin events Application events
Custom Views More services/models URL Mappings Widgets Environment detection ForgeBox Connected Coming: Themes + ColdBox 4 Support
![Page 14: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/14.jpg)
Interceptors
Majority of extensions are via Interceptors!
!Event Driven Programming
![Page 15: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/15.jpg)
IDE + Tools
ContentBox Utilities
![Page 16: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/16.jpg)
Anatomy of a Module
ModuleConfig.cfc
handlers
layouts
models
modules
Module Name(unique on disk)
box.json
views
widgets
![Page 17: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/17.jpg)
box.json
![Page 18: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/18.jpg)
ModuleConfig.cfc
Simple CFC Bootstraps your module Must exist in the root of your module folder Has public properties configure() for configuration 4 callback methods:
onLoad(), onUnload(), onActivate(), onDeactivate() Tier-detection enabled It’s an interceptor too!
![Page 19: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/19.jpg)
ModuleConfig.cfc
![Page 20: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/20.jpg)
Important Services
cbHelper@cb
settingservice@cb
adminMenuService@cb
widgetService@cb
pageService@cb
entryService@cb
contentService@cb
contentStoreService@cb
![Page 21: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/21.jpg)
CBHelper
One stop shop for anything ContentBox API Docs Module Methods
buildModuleLink( module, linkTo, queryString, ssl )
setNextModuleEvent( module, event, queryString .... )
![Page 22: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/22.jpg)
Extend: WidgetsBased on ColdBox plugins Simple interface: renderit() Self-documenting Use in editors, layouts and as ColdBox Plugins
any function renderIt(required slug, defaultValue){ var entry = entryService.findWhere({slug=arguments.slug}); if( !isNull(entry) ){ return entry.getContent(); } // default value if( structKeyExists(arguments, "defaultValue") ){ return arguments.defaultValue; } throw(message="The content slug '#arguments.slug#' does not exist",type="CustomHTMLWidget.InvalidEntrySlug"); }
![Page 23: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/23.jpg)
Extend: EditorsPage, Blog and Custom HTML Editors accept widgets via {{{ }}} notations
//Executes the renderit() by convention {{{WidgetName arg1=value arg2=value}}}
// Execute ANY method {{{WidgetName.method arg1=value arg2=value}}}
UI Way
![Page 24: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/24.jpg)
Extend: EventsBased on ColdBox interceptors Event driven programming Over 100 different events
function cbadmin_postAuthorSave(event,interceptData){ var author = arguments.interceptData.author; var currentAuthor = securityService.getAuthorSession(); // get mail payload var bodyTokens = { authorName = author.getName(), authorRole = author.getRole().getRole(), authorEmail = author.getEmail(), authorURL = CBHelper.linkAdmin("authors.editor.authorID.#author.getAuthorID()#"), currentAuthor = currentAuthor.getName(), currentAuthorEmail = currentAuthor.getEmail() }; var mail = mailservice.newMail(to=settings.cb_site_email, from=settings.cb_site_outgoingEmail, subject="#settings.cb_site_name# - Author Created - #bodyTokens.authorName#", bodyTokens=bodyTokens); // generate content for email from template mail.setBody( renderer.renderView(view="email_templates/author_new",module="contentbox") ); // send it out mailService.send( mail ); }
Extend the admin/layouts interface Use as filters Produce output
![Page 25: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/25.jpg)
Content Rendering
cb_onContentRendering cb_onCustomHTMLRendering
![Page 26: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/26.jpg)
Admin Events
![Page 27: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/27.jpg)
Admin Events
![Page 28: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/28.jpg)
Admin Events
![Page 29: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/29.jpg)
UI Module Events
![Page 30: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/30.jpg)
Security Events
![Page 31: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/31.jpg)
Media Manager Events
![Page 32: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/32.jpg)
Code Time!
![Page 33: CBDW2014 - Building ContentBox Modules](https://reader033.vdocuments.site/reader033/viewer/2022060120/5591d7eb1a28ab15468b4660/html5/thumbnails/33.jpg)
Thanks!
Q & A