Book Image

concrete5 Beginner's Guide

Book Image

concrete5 Beginner's Guide

Overview of this book

Table of Contents (19 chapters)
concrete5
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating the broken links dashboard extension


Carry out the following steps:

  1. In our package c5book, create a new directory structure controllers/dashboard/reports.

  2. Within the new directory, create a file named broken_links.php and put the following content in it to fetch the data, and pass it on to the single page by using $this->set:

    <?php 
    defined('C5_EXECUTE') or die(_("Access Denied."));
    
    class DashboardReportsBrokenLinksController extends Controller {
       
       public $helpers = array('form', 'html');
    
       public function view() {
          $db = Loader::db();
    
          $brokenLinks = array();
          $result = $db->Execute('SELECT * FROM btLinkChecker WHERE linkStatusCode NOT IN (200,302) OR linkStatusCode IS NULL');
          while ($row = $result->FetchRow()) {
             $row['page'] = Page::getByID($row['cID']);
             $row['status'] = $row['linkStatusCode'] . ' ' . $row['linkStatusName'];
             if (trim($row['status']) == '') $row['status'] = 'Server not found';...