https://github.com/coldbox-modules/cbox-cbt
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}, $ {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.
Below is an example of the finished result I've been working on:
NOTE: This was put together quickly so I wouldn't forget about it, check back later for updates
install crud-cbadmin
contentbox create module directory=modules/contentbox/modules_user name=quickCRUD
cd modules/contentbox/modules_user/quickCRUD
coldbox create orm-entity entityName=Property properties=first,last,email,updated_at:timestamp,created_at:timestamp table=myProperties primaryKey=id generator=native
contentbox create crud-cbadmin entity=models.Property pluralName=Properties moduleName=quickCRUD table=myProperties
To access the newly created CRUD page visit:
http://yoursite/cbadmin/module/quickCRUD/Properties/index
This will remove any cached version on the bleeding edge that may not match the latest version because why update a version everytime??
artifacts remove contentbox-be
artifacts remove contentbox
contentbox create orm-entity entityName=angler properties=firstName,lastName,age:numeric,createddate:timestamp
moduleName is actually module entrypoint.. i need to tweak this.
contentbox create orm-crud-cbadmin moduleName=HelloContentBox entity=models.angler
The CommandBox "orm-crud-cbadmin" is still under development and requires some tweaking before releasing. Feel free to contact me if you're interested in utilizing this before then.
This is a quick tutorial for a quick install of ContentBox using CommandBox.
Inside CommandBox:
*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.
can be created using CommandBox module "cbmigration-commands" using the following syntax:
box install cbmigrations-commands
coldbox create migration name=testTable
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;
");
}
}
I don't recommend adding “DROP TABLE” statements in production. Data could be lost. Use at your own risk.
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'