Created
June 14, 2012 21:47
-
-
Save jrast/2933178 to your computer and use it in GitHub Desktop.
Tutorial: ShortCodes in Silverstripe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
ShortcodeParser::get()->register('Gist', array('ShortCodeHandler', 'GistShortCodeHandler')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://gist.github.com/{$GistID}.js<% if File %>?file=$File<% end_if %>"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<-- Hier kommt dann das Template hin --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Gist id=2933178 file=ShortCode.txt] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ShortCodeHandler { | |
public static function GistShortCodeHandler($arguments, $caption = null, $parser = null) { | |
if (empty($arguments['id'])) | |
return; | |
$customise = array(); | |
$customise['GistID'] = $arguments['id']; | |
$customise['File'] = key_exists('file', $arguments) ? $arguments['file'] : false; | |
$template = new SSViewer('Gist'); | |
return $template->process(new ArrayData($customise)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ShortCodeHandler { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment