My Custom Block Isn't working
PermalinkThis is a fresh install in Concerete5.7.
I've tried creating my own Custom Block called CorporateEmployee (the folder in applications/blocks/ is called corporate_employee. The block installed correctly, but any time I try to drag the block onto an area it simply sits there idle, with the loading cursor icon going. It never actually adds the block to the area.
Here's all my block code.
add.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $al = Loader::helper('concrete/asset_library'); ?> <div class="ccm-ui"> <div class="alert-message block-message info"> <?php echo t("This form is used to add corporate level employees.") ?> </div> <?php echo $form->label('name', t('Name')); echo $form->text('name'); echo $form->label('title', t('Title')); echo $form->text('title'); echo $form->label('biography', t('Biography'); echo $form->text('biography');
controller.php
<?php namespace Application\Block\CorporateEmployee; use Concrete\Core\Block\BlockController; class Controller extends BlockController { protected $btTable = "btCorporateEmployees"; protected $btInterfaceWidth = "350"; protected $btInterfaceHeight = "300"; public function getBlockTypeName() { return t('Corporate Employees'); } public function getBlockTypeDescription() { return t('This block is used to manage existing & new corporate employees.'); } }
db.xml
<?xml version="1.0"?> <schema version="0.3"> <table name="btCorporateEmployees"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="name" type="X2"> <default value="" /> </field> <field name="title" type="X2"> <default value="" /> </field> <field name="biography" type="X2"> <default value="" />
edit.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $al = Loader::helper('concrete/asset_library'); ?> <div class="ccm-ui"> <div class="alert-message block-message info"> <?php echo t("This form is used to edit corporate level employees.") ?> </div> <?php echo $form->label('name', t('Name')); echo $form->text('name', $name); echo $form->label('title', t('Title')); echo $form->text('title', $title); echo $form->label('biography', t('Biography'); echo $form->text('biography', $biography);
view.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")) ?> <div class="row full-width"> <div class="row"> <?php echo($fID); ?> <div class="col-lg-7 col-lg-offset-1"> <h3><span class="name"><?php echo($name); ?></span><span class="title"><?php echo($title); ?></span></h3> <hr class="little-orange"> <p><?php echo($biography); ?></p> </div> </div> </div>
Problem solved, thanks.
when adding a new employee, the form appears and on the last field I get
The identifier fID is missing for a query of Concrete\Core\File\File
Are you experiencing that?
I do not see where/why this would be happenning in your code.
But I also want ot ask, Where is $fID coming from? The problem is, in my code (same as yours) it is null. But I assume yours is not.
echo $form->label('biography', t('Biography');
need to be
echo $form->label('biography', t('Biography'));
in add.php and edit.php