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
controller.php
db.xml
edit.php
form_setup_html.php
view.php
The second block is like the HTML Block. Here are the files and code for this block:
add.php
composer.php
controller.php
db.xml
edit.php
form_setup_html.php
scrapbook.php
view.php
I'm not an expert PHP programmer, but I can usually figure my way around.
THANK YOU!
George
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
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
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>';
Viewing 15 lines of 16 lines. View entire code block.
view.php
The second block is like the HTML Block. Here are the files and code for this block:
add.php
composer.php
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.");
Viewing 15 lines of 52 lines. View entire code block.
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
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
view.php
I'm not an expert PHP programmer, but I can usually figure my way around.
THANK YOU!
George