Category Filtering: 'dev-contentbox-modules'

Remove Filter


Flexible and Advanced ContentBox Layouts for Custom Modules

UPDATE: Check out ColdBox CBT instead.

https://github.com/coldbox-modules/cbox-cbt

Origional Post:

I had an epiphany today trying to figure out a flexible way to re-use a ContentBox module in such a way that each view could be customized per client without the need of creating hundreds of individual "view" files.

If you have not already created a custom ContentBox Themed Module let me suggest you stop what you're doing and head over to https://www.ortussolutions.com/blog/the-12-tips-of-contentbox-christmas-day-6-themed-modules and get started.

Sample Handler:

component {

	// DI
	property name='ContactService' inject='ContactService';
	property name='MessageBox' inject='MessageBox@cbMessageBox';

	function index() {
		list( argumentCollection=arguments );
	}

	function list(event,rc,prc){
		// Query our data just like normal.
		prc.qContacts		=	contactService.list();
		
		// To use the data in ContentBox as a dynamic variable we need to flatten things out a bit.
		prc.demoName 		=	prc.qContacts.name;
		prc.demoAddress1 	=	prc.qContacts.address1;
		prc.demoCity 		=	prc.qContacts.city;
		prc.demoState 		=	prc.qContacts.state;
		prc.demoZip 		=	prc.qContacts.zip;
		cbHelper.prepareUIRequest('pagesNoHeader');
		event.setView( "home/list" );

}		

Sample View home/list.cfm

<cfoutput>
#cb.contentStore('demo-list', 'ContentStore item not found')#
</cfoutput>

The above view will look for a ContentStore item slug called demo-list.

ContentBox ContentStore demo-list

This is where you will create the layout for your data that can be edited and modified without having to edit the core view files. This concept is a work in progress, but it does work and I have a feeling it will be expanded on in the future.

<div class="row">
	<div class="col-md-8">
		<h1>$ {prc:demoName}</h1>
		$ {prc:demoAddress1}<br />
		$ {prc:demoCity},&nbsp; $ {prc:demoState} $ {prc:demoZip}<br />
	</div>
	<div class="col-md-4">
		<h4>Custom/Editable Section</h4>
		<p>This section can contain specific information outside of the module.</p>
	</div>
</div>
<div class="row">
	<div class="col-md-12">
		{ {{RenderView view='home/demoView' module='myModule' cache='false'}} }
	</div>
</div>

RenderView demoView

Renders the above view.

Live Demo

Below is an example of the finished result I've been working on:

Editor Preview

NOTE: This was put together quickly so I wouldn't forget about it, check back later for updates

Laravel Style Database Migrations for ContentBox & ColdFusion

Download

 

Introduction

*Laravel style database migrations for ContentBox.

Migrations are like version control for your database, allowing your team to easily modify and share the application's database schema. If you have ever had to tell a teammate to manually add a column to their local database schema, you've faced the problem that database migrations solve.

Sample Migration

can be created using CommandBox module "cbmigration-commands" using the following syntax:

box install cbmigrations-commands
coldbox create migration name=testTable

/modules/contentbox/modules_user/YOURMODULENAME/resources/database/migrations/YYYY_MM_DD_HHMMSS_testTable.cfc
component {
    function up() {
        queryExecute("
            CREATE TABLE testTable (
                `id` int NOT NULL AUTO_INCREMENT,
                `fname` varchar(255),
                `lname` varchar(255),
                `email` varchar(255),
                PRIMARY KEY (`id`)
            ) COMMENT='';         
        ");
    }

    function down() {
        queryExecute("
           DROP TABLE testTable;
        ");
    }
}

Notes

I don't recommend adding “DROP TABLE” statements in production. Data could be lost. Use at your own risk.

Attribution

This ContentBox module is built from a ColdBox Module created by Eric Peterson called cbmigrations

                                                  $7                        
                                                  $$$                         
                                                 .$$$$                        
                                                 :$$$$.                       
                                                 $$$$$                        
                                               .$$$$$$.                       
                                               $$$$$$$..,                     
                                              $$$$$$+  .$                     
                                             $$$$$=    .Z$                    
                                           .$$$$       .$$Z                   
                                         $$$.$$$$$$$$$$$$$+ . ..             
                                      ..$$$$$$$$$$$$$$7~,......,:+$$I         
                                    .$$$$7.  .                                
888      888                      .+$...              888                                      
888      888                     ..                   888                                      
888      888                                          888                                      
88888b.  888 888  888  .d88b.  888  888  888  8888b.  888888 .d88b.  888d888                   
888 "88b 888 888  888 d8P  Y8b 888  888  888     "88b 888   d8P  Y8b 888P"                     
888  888 888 888  888 88888888 888  888  888 .d888888 888   88888888 888                       
888 d88P 888 Y88b 888 Y8b.     Y88b 888 d88P 888  888 Y88b. Y8b.     888                       
88888P"  888  "Y88888  "Y8888   "Y8888888P"  "Y888888  "Y888 "Y8888  888 

             .dP"Y8  dP"Yb  88     88   88 888888 88  dP"Yb  88b 88 .dP"Y8 
             `Ybo." dP   Yb 88     88   88   88   88 dP   Yb 88Yb88 `Ybo." 
             o.`Y8b Yb   dP 88  .o Y8   8P   88   88 Yb   dP 88 Y88 o.`Y8b 
             8bodP'  YbodP  88ood8 `YbodP'   88   88  YbodP  88  Y8 8bodP'