Custom Block Issue

Permalink
Hi,

I built two similar blocks for a client so they could easily add a heading and content and I could style it anyway I wanted. My blocks work except when the client uses the "Insert Link to Page", the link goes to the dynamic cID instead of the permalink. I think my code is just missing a little bit of code to translate the cID link into a permalink. Any insight or fix would be greatly appreciated! (I know there's a Designer Block addon but the client has used my custom block in a lot of places and has no budget for me to go in and convert them all to a Designer addon. I'm hoping a quick fix to my custom blocks would solve this easily!)

Site:http://chaplaincyinstitute.org/support-chi/donate/... (the links in the right sidebar in the blocks titled "Giving Circles", "More Information" and "More Ways to Support ChI").


The first block is like the Content Block. Here are the files and code for this block:

add.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$this->inc('form_setup_html.php');
?>


controller.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
   class TCISideColumnBoxBlockController extends BlockController {
      protected $btTable = 'btTCISideColumnBox';
      protected $btInterfaceWidth = "600";
      protected $btInterfaceHeight = "400";
      public function getBlockTypeDescription() {
         return t("Adds a side column box to the sidebar.");
      }
      public function getBlockTypeName() {
         return t("Side Column Box");
      }
   }
?>


db.xml

<?xml version="1.0"?>
<schema version="0.3">
   <table name="btTCISideColumnBox">
      <field name="bID" type="I">
         <key />
         <unsigned />
      </field>
      <field name="heading" type="C" size="36"></field>
      <field name="bodycontent" type="X2"></field>
   </table>
</schema>


edit.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$this->inc('form_setup_html.php');
?>


form_setup_html.php

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$al = Loader::helper('concrete/asset_library');
echo '<div class="ccm-block-field-group">';
echo '<p style="font-weight:bold;">' . t('Heading') . '</p>';
echo $form->text('heading', $heading, array('style' => 'width: 550px'));
echo '</div>';
echo '<div class="ccm-block-field-group">';
echo '<p style="font-weight:bold;">' . t('Body Content') . '</p>';
Loader::element('editor_init');
Loader::element('editor_config');
Loader::element('editor_controls', array('mode' => 'full'));
echo $form->textarea('bodycontent', $bodycontent, array('class' =>
'ccm-advanced-editor'));
echo '</div>';


view.php

<?php   
defined('C5_EXECUTE') or die("Access Denied."); 
?>
<div class="sideColumnBox">
<?php
$html = Loader::helper('html');
echo "<div class=\"sideColumnBoxHeading\">{$heading}</div>";
echo "<div class=\"sideColumnBoxBody\">{$bodycontent}</div>";
?>
</div>




The second block is like the HTML Block. Here are the files and code for this block:

add.php

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$controllerObj=$controller;
?>
<?php  $this->inc('form_setup_html.php');


composer.php

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$form = Loader::helper('form');
print $form->textarea($this->field('content'), $content, array(
));


controller.php

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
Loader::block('library_file');
class TCISideColumnHTMLBoxBlockController extends BlockController {
   protected $btTable = 'btTCISideColumnHTMLBox';
   protected $btInterfaceWidth = "600";
   protected $btWrapperClass = 'ccm-ui';
   protected $btInterfaceHeight = "465";
   protected $btCacheBlockRecord = true;
   protected $btCacheBlockOutput = true;
   protected $btCacheBlockOutputOnPost = true;
   protected $btCacheBlockOutputForRegisteredUsers = true;
   public $content = "";   
   public function getBlockTypeDescription() {
      return t("Adds a side column HTML box to the sidebar.");


db.xml

<?xml version="1.0"?>
<schema version="0.3">
   <table name="btTCISideColumnHTMLBox">
      <field name="bID" type="I">
         <key />
         <unsigned />
      </field>
      <field name="heading" type="C" size="36"></field>
      <field name="content" type="X2"></field>
   </table>
</schema>


edit.php

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$controllerObj=$controller;
?>
<?php  $this->inc('form_setup_html.php', array('controllerObj' => $controller)); ?>


form_setup_html.php

<?php  defined('C5_EXECUTE') or die("Access Denied.");
echo '<div class="ccm-block-field-group">';
echo '<p style="font-weight:bold;">' . t('Heading') . '</p>';
echo $form->text('heading', $heading, array('style' => 'width: 550px'));
echo '</div>';
?>
<textarea id="ccm-HtmlContent" name="content" style="width: 98%; height: 440px"><?php echo htmlentities($controllerObj->content, ENT_COMPAT, APP_CHARSET) ?></textarea>


scrapbook.php

<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<div id="HTMLBlock<?php echo intval($bID)?>" class="HTMLBlock" style="max-height:300px; overflow:auto">
<?php echo TCISideColumnHTMLBoxBlockController::xml_highlight(($content)) ?>
</div>


view.php

<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<div class="sideColumnBox">
<?php
echo "<div class=\"sideColumnBoxHeading\">{$heading}</div>";
echo "<div class=\"sideColumnBoxBody\">{$content}</div>";
?>
</div>



I'm not an expert PHP programmer, but I can usually figure my way around.

THANK YOU!
George

emsconcrete