-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bf7846
commit ddc3653
Showing
5 changed files
with
151 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace Grav\Plugin\Shortcodes; | ||
use Thunder\Shortcode\Shortcode\ShortcodeInterface; | ||
|
||
class DataTablesScript extends Shortcode | ||
{ | ||
public function init() | ||
{ | ||
$this->shortcode->getHandlers()->add('dt-script', function(ShortcodeInterface $sc) { | ||
$content = trim($sc->getContent()); | ||
while ( preg_match('/\<[^>]*\>/', $content, $matches)) { // strip tags from both ends | ||
$tag = strlen($matches[0]); | ||
$len = strlen($content); | ||
$content = substr($content,$tag,$len-$tag-$tag-1); | ||
} | ||
if ( isset($this->grav['datatables'] )) $this->grav['datatables'] .= $content; | ||
return ''; | ||
}); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{{ content }} | ||
<script> | ||
$(document).ready( function () { | ||
$('#{{ id }}').DataTable({% if options %}{{ options }} {% endif %}); | ||
$('#{{ id }}').DataTable({% if options %}{{ options }}{% endif %}); | ||
{% if snippet %} | ||
var selector = '#{{ id }}'; | ||
{{ snippet }} | ||
{% endif %} | ||
} ); | ||
</script> |