Creating block types is a great way to add custom functionality to a website. This is the preferred way to add things like calendars, dealer locators, or any other type of content that is visible and repeatable on the frontend of the website.
The code for this recipe is available to download from the book's website for free. We are going to create a fully functioning block type that will display content on our website.
The steps for creating a custom block type are as follows:
First, you will need to create a directory in your website's root
/blocks
directory. The name of the directory should be underscored and will be used to refer to the block throughout the code. In this case, we will create a new directory called/hello_world
.Once you have created the
hello_world
directory, you will need to create the following files:controller.php
db.xml
form.php
add.php
edit.php
view.php
view.css
Now, we will add code to each of the files. First, we need...