Library ID conflict?
Permalink
I put together a custom block drawing 2 images from the library - one static image, and another I extracted from the preexisting "Image" block from /concrete/blocks. There seems to be a conflict now, where only one of the two images is showing.
Here's my code:
controller.php:
add.php:
edit.php:
db.xml:
view.php:
If anyone could take a look at my code and suggest what I need to do to separate the libraries... I've tried renaming $bt, to no avail. Any ideas?
Here's my code:
controller.php:
<?php class WorkGridBlockController extends BlockController { var $pobj; protected $btDescription = "Work grid."; protected $btName = "Work Grid"; protected $btTable = 'btWorkGrid'; protected $btInterfaceWidth = "350"; protected $btInterfaceHeight = "300"; /** * Used for localization. If we want to localize the name/description we have to include this */ public function getBlockTypeDescription() { return t("Adds images and onstates from the library to pages."); } public function getBlockTypeName() {
Viewing 15 lines of 80 lines. View entire code block.
add.php:
<?php $al = Loader::helper('concrete/asset_library'); echo $al->file('ccm-b-file', 'fID', t('Choose File'), $bf) ?> <?php echo $form->label('content', 'Name');?> <?php echo $form->text('content', array('style' => 'width: 320px'));?> <?php $bf = File::getByID($fID);?> <?php defined('C5_EXECUTE') or die(_("Access Denied.")); $includeAssetLibrary = true; $assetLibraryPassThru = array( 'type' => 'image' ); $al = Loader::helper('concrete/asset_library'); ?>
Viewing 15 lines of 27 lines. View entire code block.
edit.php:
<?php $al = Loader::helper('concrete/asset_library'); echo $al->file('ccm-b-file', 'fID', t('Choose File'), $bf) ?> <?php echo $form->label('content', 'Name');?> <?php echo $form->text('content', $content, array('style' => 'width: 320px'));?> <?php $file = File::getByID($fID); $filePath = $file->getVersion()->getRelativePath();?> <?php defined('C5_EXECUTE') or die(_("Access Denied.")); $includeAssetLibrary = true; $assetLibraryPassThru = array( 'type' => 'image' ); $al = Loader::helper('concrete/asset_library');
Viewing 15 lines of 36 lines. View entire code block.
db.xml:
<?xml version="1.0"?> <schema version="0.3"> <table name="btWorkGrid"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="fID" type="I"> <unsigned /> <default value="0" /> </field> <field name="fOnstateID" type="I"> <unsigned /> <default value="0" /> </field>
Viewing 15 lines of 22 lines. View entire code block.
view.php:
<?php $file = File::getByID($fID); $filePathy = $file->getVersion()->getRelativePath(); ?> <div style="height: auto; width: auto; float: left;"><?php echo $content?></div> <div style="height: auto; width: auto; float: left;"> <?php echo '<img src="' . $filePath . '" />'; ?> </div> <?php defined('C5_EXECUTE') or die(_("Access Denied.")); echo($controller->getContentAndGenerate()); ?>
If anyone could take a look at my code and suggest what I need to do to separate the libraries... I've tried renaming $bt, to no avail. Any ideas?
For those in the future who were as confused as I was, what you need to do is add a new field in db.xml, and give it a unique name ("tID", for example). Refresh via dashboard.
Then go back to view.php, edit.php, and add.php and change the ID in the first library class (right terminology?) on each page to reflect "tID".
:)