This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Dashboard controllers

Since most (likely all) Dashboard pages will need to utilize at least some bit of logic, it’s best to place that code in a controller file. The controller for your custom dashboard page should be located in its own proper override directory:

your_site_root/dashboard/controllers/dashboard/awesome/controller.php

Here’s an example of how one would create a rudimentary dashboard controller and pass a variable’s value back to the view:

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
class DashboardAwesomeController extends Controller {

    public function view() {
        $cat = "mittens";
        $this->set('cat', $cat);
    }
}

Now we can echo $cat in view.php and it’ll return “mittens” as expected.

So how does the concete5 dashboard work? In a nutshell, the dashboard consists of an assortment of single pages that are built during installation. Take a look at concrete/single_pages/dashboard and you’ll see all the familiar dashboard panes represented.

Extending the Dashboard

We can add a new Dashboard page as easily as we’d add a new single page anywhere else on our site. Let’s call ours “Awesome”. To start, we’ll make a new dashboard directory in your single_pages override folder, and a folder for the page we’re creating, within:

your_site_root/single_pages/dashboard/awesome

Inside this folder, let’s create a new file and name it view.php. This will be our new dashboard pane. Let’s leave the file empty for now.

Now it’s time to add our new single page. Go to Dashboard >  Single Pages. Under “Add Single Page”, enter the path to our new single page:

dashboard/awesome

extending_dashboard.pnh.png

Click the Add button, and we’ve created our new Dashboard single page. Check it out in our Dashboard dropdown menu here:

extending_dashboard2.png

Now we can visit the page, but it’s blank (as you might expect). We’ll need to add some code to view.php to get anything to show up, natually. We’ll start off with the following items:

  1. The standard ‘C5_EXECUTE’  line that begins all our php files.
  2. A call to load the dashboard pane header wrapper helper.
  3. Some content to display.
defined('C5_EXECUTE') or die(_("Access Denied."));    
echo  Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Awesome'), t('This is awesome.')); ?>
<h1>Hello!</h1>
<p>We've just created a new Dashboard page.</p>

The dashboard pane header wrapper sets up the main page area and its title. Here’s how the page looks now:

extending_dashboard3.png

The second argument of getDashboardPaneHeaderWrapper (displayed above as ‘This is awesome’) contains a descriptive bit of text that is displayed when a user clicks the Help icon:

extending_dashboard4.png

Dashboard subpages

Adding a subpage is as easy as creating another another page at the same level as the new page. Simply copying the view.php we created a few moments ago, then renaming it to subpage.php nets this result:

 

extending_dashboard5.png

Loading Conversation