Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Links are breaking inside my custom shortcode


Go to End


774 Views

Avatar
Murph86

Community Member, 2 Posts

3 December 2014 at 5:51am

Edited: 03/12/2014 5:51am

Hi guys,

I've been playing around with custom shortcodes to be able to make column layouts in the TinyMCE editor. So far I've got everything working nicely, but I've run into one problem and I'm having a hard time find any answers on resolving it. It seems that any site links inside my shortcode end up being broken. The link ends up looking something like this: www.mysite.com/[sitetree_link,id=3]. I read in the documentation that shortcodes can't be nested, so I'm wondering if that is what's causing the page link shortcode to break... If anyone knows a workaround for this it would be greatly appreciated!

Here is the code I've got so far:

Page.php
public static function TwoColumnShortCodeHandler($arguments, $content = null, $parser = null) {
$customise = array();
$customise['content'] = $content;
$customise = array_merge($customise,$arguments);
$template = new SSViewer('TwoColumn');

return $template->process(new ArrayData($customise));
}

_config.php
ShortcodeParser::get('default')->register('TwoColumn', array('Page', 'TwoColumnShortCodeHandler'));

TwoColumn.ss
<div class="two-column">$content</div>

Cheers,
Ryan