Basic Block Development

Part Two

What is the tools folder?

Generally, concrete5 has some scripts in the tools/ folder that are generally small scripts meant to be accessed from anywhere in the site. For instance, concrete5's upgrade script is actually a tool. The main tools of concrete5 are in concrete/tools/.

Blocks can have tools as well. If a block type has its own tools/ folder it might want to have some sort of pop-up dialog that does something interesting, or it might employ some means of interacting with the block outside of edit mode. It's kind of an advanced topic so knowing what that folder if for is enough for now.


Templates are alternate views for rendering your block. It's a good way to use the same data but present a totally different block. The usual way to do this is to just copy view.php into a folder named for your template, then make modifications. If you want that block's view.js and view.css to be available to the template, those need to be copied into the tempate folder too. Check out this how-to for a more in-depth look at templates.

Javascript and CSS

Blocks can include javascript or css in two different ways. The first way is to include a view.css and view.js in your block's folder. You can also put css/ and js/ folders in your block, and all the css or javascript in those folders will also be included when your block is added to a page. The distinction is that things in css/ and js/ will always be added to your block, but the view.js and view.css can change according to your template.

Contact Info Block

The contact information block that Andrew runs through is not included in the core, but essentially all it is is a block that holds four text fields and one number for a File ID. It also uses the file manager interface, but that is discussed in the advanced block development videos.

Andrew also introduces a few more concepts that will be covered in Advanced Block Dev.

An interesting thing to note is that a block will not actually delete until the block is no longer referenced in any version of any page in your site. Otherwise the block record will persist so that rolling back to an older version of a page.

Recent Discussions on this Topic

Custom Block View Tutorial

Attached is a white paper on creating custom block views. I am finding many C5 users do not understand this concept and even hesitate to modify purchased addons. I hope this is helpful. Please PM me if you have any additions or corrections and I …

Building a block with library image input?

I'm trying to build a block that has the ability to pull an image from the library (or, since I'm desperate, from anywhere, even a remote URL), but I can't figure it out, and I'm new to PHP... Does anyone have any pointers? I tried reading http://phple…

Check it out: custom block creator!

*** This package is now available on the marketplace: *** I've made a "custom block creator" which aims to solve the problem of allowing you (as the site designer) to specify exactly how som…

Adding smarter DISQUS to your concrete5

Guys, I've just finished figuring out a smarter way to implement Disqus, a third-party commenting system Sometime, you don't bother users to register on your site, but comment using Facebook, twitter or other social ID. Disqus is a fine comment s…

Issues with pasting a block from clipboard

When I paste my custom block from clipboard, it does copies the block but it does not seem functional. Do I need to use duplicate() function in my controller to get this to work properly? Can someone give me an example of using duplicate() function?