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 block controller


Carry out the following steps:

  1. Create another file named controller.php in our new add-on directory.

  2. Put the following content in it:

    <?php 
    defined('C5_EXECUTE') or die(_("Access Denied."));
    class ProductInformationBlockController extends BlockController {
       
       protected $btTable = 'btProductInformation';
       protected $btInterfaceWidth = "590";
       protected $btInterfaceHeight = "450";
    
       public function getBlockTypeDescription() {
          return t("Embeds a Product Information in your web page.");
       }
       
       public function getBlockTypeName() {
          return t("Product Information");
       }
          
       function view(){ 
          $this->set('bID', $this->bID);
       }
       
       function save($data) { 
          parent::save($data);
       }
       
       function getPicture() {
          if ($this->fIDpicture > 0) {
             return File::getByID($this->fIDpicture);
          }
          return null;
       }
       
    }
    ?>
    

What just happened?

The file we created is the one...