Skip to content

Instantly share code, notes, and snippets.

@plfstr
Created September 20, 2014 15:15
Show Gist options
  • Save plfstr/336b5f2cc96233bad991 to your computer and use it in GitHub Desktop.
Save plfstr/336b5f2cc96233bad991 to your computer and use it in GitHub Desktop.
Kirbytext plugin for Kirby CMS to create <figure> wrapped blockquotes, with optional <figcaption>
<?php
# ***Must be included as part of plugins/kirbytext.extend.php*** - Follow guidance here http://getkirby.com/blog/kirbytext
# Kirby CMS Figure Quote Plugin - Forked from https://gist.github.com/bastianallgeier/2924148#file-figure-php
# Blockquote markup best practice followed from http://alistapart.com/blog/post/more-thoughts-about-blockquotes-than-are-strictly-required
# Include in a post as follows (figquote: Example quotes need to be good ones. source: Mr Example)
/* Example CSS to target blockquote:
.blockquote {}
.blockquote p {}
.blockquote blockquote {}
.blockquote figcaption:before {content: "—";}
*/
/*
class kirbytextExtended extends kirbytext {
function __construct($text=false, $markdown=true, $smartypants=true {
parent::__construct($text, $markdown, $smartypants);
*/
// define custom tags
$this->addTags('figquote');
// define custom attributes
$this->addAttributes('source');
/* } */
function figquote($params) {
$html = '<figure class="blockquote">';
if(!empty($params['figquote'])) {
$html .= '<blockquote><p>' . $params['figquote'] . '</p></blockquote>';
if(!empty($params['source'])) {
$html .= '<figcaption>' . $params['source'] . '</figcaption>';
}
}
$html .= '</figure>';
return $html;
}
/* } */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment