Custom Block not using Pretty URLs
Permalink
I've created 2 custom blocks based off of the Content Block and the HTML Block. The reason for the customization was to create two areas per block for the client: a heading area and body content area for the block so that I could separately style them.
The issue is that when the client uses "Insert Link to Page" to link to another page on the site, a URL like, for example,http://example.com/index.php?cID=167 isn't converted to a pretty URL.
The default Concrete Block converts those "Insert Link to Page" links, but I'm not sure how to do it for my custom block. I feel like I'm just missing a little bit of code. Any help would be greatly appreciated.
I've attached some screenshots: custom block interface, the HTML of that block, and an example of what a custom block looks like on the frontend. The screenshot custom-block-look.png shows where the Heading appears ("Choose Your Path") and the Body Content ("Not sure which program...").
I've also put the code for the relevant custom block files below.
view.php
form_setup_html.php
controller.php
Can anyone help me?
Thanks!
George
The issue is that when the client uses "Insert Link to Page" to link to another page on the site, a URL like, for example,http://example.com/index.php?cID=167 isn't converted to a pretty URL.
The default Concrete Block converts those "Insert Link to Page" links, but I'm not sure how to do it for my custom block. I feel like I'm just missing a little bit of code. Any help would be greatly appreciated.
I've attached some screenshots: custom block interface, the HTML of that block, and an example of what a custom block looks like on the frontend. The screenshot custom-block-look.png shows where the Heading appears ("Choose Your Path") and the Body Content ("Not sure which program...").
I've also put the code for the relevant custom block files below.
view.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.
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"); } } ?>
Can anyone help me?
Thanks!
George
Also, there's a really useful (and free) add-on which might do what you need:
http://www.concrete5.org/marketplace/addons/designer-content/...
jordi
http://www.concrete5.org/marketplace/addons/designer-content/...
jordi
Just an idea: maybe you could have a look at how the content block works.
If you open the view.php it seems the content block uses a "getContent" method.
If you open the controller (/concrete/core/controllers/blocks/content.php), you'll see the getContent method is using the method translateFrom, which runs some preg_replace calls (and also another method called replaceCollectionID) to add support for the links.
It seems this is how the default Content Block replaces the cID parameter with pretty urls.
Hope that helps!
Jordi