customising image block to give fixed horizontal width
Permalink
I want to make an image block available to users that provides a subset of the functionality that the default concrete image block provides, initially just removing the decisions as to what size the image is rendered at from the editor and passing that decision over to the theme designer.
is there either:
* a standard way of disabling controls and / or replacing controls with constant hidden values?
* a standard pattern for overriding an existing core concrete block and then editing the bits as appropriate? ie I could copy all of concrete/blocks/image/* into my own block directory, but then I assume that I would have to change all the block names and db tables so that it didn't get overlap with the default functionality?
I think that my ideal solution would be to create a new block type (eg "Small Image") which just contained the minimum amount of files to declare that it extended the core image block type and a version of form.php that I'd replaced the elements that I didn't want edited with constant values. I would create a number of different ones ("Medium Image", "Large Image" etc) and they would all be writing to the btContentImage table that the default image block uses, but with constrained variables.
Might this approach work or am I barking up completely the wrong tree? Are there any howtos on either this or alternative approaches that I could read?
is there either:
* a standard way of disabling controls and / or replacing controls with constant hidden values?
* a standard pattern for overriding an existing core concrete block and then editing the bits as appropriate? ie I could copy all of concrete/blocks/image/* into my own block directory, but then I assume that I would have to change all the block names and db tables so that it didn't get overlap with the default functionality?
I think that my ideal solution would be to create a new block type (eg "Small Image") which just contained the minimum amount of files to declare that it extended the core image block type and a version of form.php that I'd replaced the elements that I didn't want edited with constant values. I would create a number of different ones ("Medium Image", "Large Image" etc) and they would all be writing to the btContentImage table that the default image block uses, but with constrained variables.
Might this approach work or am I barking up completely the wrong tree? Are there any howtos on either this or alternative approaches that I could read?
thank you - very helpful.
so if I was wanting to do this inside a package then I would add the override files inside the packages/xxx/blocks/image/ and then install the image blocktype in my controller.php for the package and then it would override bits of the default image block?
this is definitely worth investigating, but it would still only give me a single customised image block. is there another model which lets me implement a block that is a decorator of an existing block? ie so that I could make multiple versions of the Image Block that the editor could choose between and each would differ from the default Image Block in a slightly different way?
so if I was wanting to do this inside a package then I would add the override files inside the packages/xxx/blocks/image/ and then install the image blocktype in my controller.php for the package and then it would override bits of the default image block?
this is definitely worth investigating, but it would still only give me a single customised image block. is there another model which lets me implement a block that is a decorator of an existing block? ie so that I could make multiple versions of the Image Block that the editor could choose between and each would differ from the default Image Block in a slightly different way?
Do you mean, be able to define different display styles for an existing block? To do that, you can create custom views that you would place in the appropriate override folder.
If you're just creating a custom view for an existing block, you would create a directory in your /blocks directory that matches the directory name of the block. Here is more info about doing that:
http://www.concrete5.org/documentation/developers/blocks/directory-... (look for "custom views")
If you're doing this in the context of a package, the override directory would go inside your package directory, depending upon which block you are creating the custom view for. It sounds like you are already somewhat familiar with packages, but if you haven't done so, here is a good doc to become familiar with:
http://www.concrete5.org/documentation/developers/system/packages...
If you're just creating a custom view for an existing block, you would create a directory in your /blocks directory that matches the directory name of the block. Here is more info about doing that:
http://www.concrete5.org/documentation/developers/blocks/directory-... (look for "custom views")
If you're doing this in the context of a package, the override directory would go inside your package directory, depending upon which block you are creating the custom view for. It sounds like you are already somewhat familiar with packages, but if you haven't done so, here is a good doc to become familiar with:
http://www.concrete5.org/documentation/developers/system/packages...
Have you considered using the excellent Designer Content add-on by Jordan Lev?
http://www.concrete5.org/marketplace/addons/designer-content/...
http://www.concrete5.org/marketplace/addons/designer-content/...
In short, yes, you can do this. Here are a couple of links to relevant docs to help get you pointed in the right direction...
All about block architecture and creating custom blocks:
http://www.concrete5.org/documentation/developers/blocks/overview/...
And here's an update to the info on overriding core block types that took effect with v 5.6.0:
http://www.concrete5.org/documentation/how-tos/developers/overridin...