Basic Block Development

Part Three

Out of Scope

Most of this video is the trainees asking questions about topics already covered or topics that are advanced, and Andrew musing on these subjects. It is informative and interesting to watch but the annotation for this installment is sparse as a result. But please don't skip this video! If you miss the topics covered in the New Concepts summary, you will be confused.

The video starts with Andrew explaining some new dashboard-only blocks that are not part of the editing experience. Then Andrew runs through how you can have more than one DB table in a block. This is covered in the Advanced Block videos.

If you are only here to learn how to make blocks, you can skip ahead to 7:15.

Back to templates

Andrew backs it up and talks about templates some more. It's interesting to watch but you can skip ahead again to 18:40 if you feel comfortable with templates. At that point Andrew opens up the file concrete/blocks/page_list/tools/rss.php. Most of the rest of this video is specific to the discussion that Andrew is having with the trainees, and is not pertinent to basic block building, though it is interesting.

New Concepts

Towards the end of this video, Andrew brings up a few critical functions and ideas. In all block controllers you will see a function called view(). This is called when a block is rendered and it is the place to use $this->set() and define any data you want to pass to your view. The function on_page_view() is incredibly useful, it runs before the view() function, and you can use it to include javascript or css. Check out the controller for the video block, concrete/core/controllers/blocks/video.php to see this in practice.

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…

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…

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…

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?