Open the package controller (located at /packages/cookbook_events/controller.php
) in your code editor. Add a new method to the controller class named install
. It should look like the following code snippet:
public function install() { $pkg = parent::install(); // Add the dashboard pages $mainPage = SinglePage::add('/dashboard/cookbook_events', $pkg); $listPage = SinglePage::add('/dashboard/cookbook_events/list', $pkg); $addPage = SinglePage::add('/dashboard/cookbook_events/add', $pkg); // install the block type BlockType::installBlockTypeFromPackage('cookbook_events', $pkg); }
What's going on here? Well, if you recall, we created three single pages with controllers to be used for the dashboard interface. These pages will need to be added to the site map, so we hook into the package's installation routine to make sure that they get installed when the package is installed.
Next, we also install the block type. This will ensure that our block is available to use on the frontend of the website.
When concrete5 installs the package, it will run our package's db.xml
file, creating the database tables defined in there. This will allow our package to remain completely portable, and it can be installed in any concrete5 website.
Let's install the package now.
Visit the package installation page on your concrete5 site, located at /dashboard/extend/install/
. You should see the events package awaiting installation, as shown in the following screenshot:
Click on the Install button on the package. If all goes well, the package will be installed! We should have some new pages on the dashboard, so visit /dashboard/cookbook_events
.
Did you notice what happened? When we visit the /dashboard/cookbook_events
page, it redirects us to /dashboard/cookbook_events/list/
. This is intentional. The way that the dashboard is organized requires add-ons to have a parent page. That will allow our Event List and Add Event single pages to appear in the dashboard menu correctly.
This list page is still completely empty. Let's add some HTML to it and fill it out.