Hi,
I am totally new to Kirby, to Javascript and to PHP - so please apologize if things are very obvious
I found a plugin I would like to use which introduces a new KirbyTag to render BibTex information: GitHub - PhilippMundhenk/Kirby-BibTeX: Interactive publications lists with JavaScript + Bibtex
Unfortunately, the plugin is not maintained anymore and was written for Kirby2.
The plugin reads a text file in BibTex format which lists several entries and uses some Javascript to render each entry of the BibTex file as html.
Based on the information I found I tried to convert it to a Kirby3 plugin and I got somewhere. I find the html in the source of my page and also the KirbyTag option of the bib Filename is correctly passed to the plugin, but the Javascript is throwing an error so no content is created by the Javascript.
The original plugincode:
<?php
kirbytext::$tags['bibtex'] = array(
'html' => function($tag) {
$html = '<div>';
$html .= '<link rel=stylesheet href=assets/bibtex/bib-publication-list.css>';
$html .= '<div class=publications>';
$html .= '<table id=pubTable class=display>';
$html .= '</table>';
$html .= '</div>';
$html .= '<script type=text/javascript src=https://code.jquery.com/jquery-2.1.4.min.js></script>';
// $html .= '<script type=text/javascript src=https://code.jquery.com/jquery-1.6.4.min.js></script>';
$html .= '<script type=text/javascript src=https://cdn.datatables.net/1.6.2/js/jquery.dataTables.min.js></script>';
$html .= '<script type=text/javascript src=assets/bibtex/BibTex-0.1.2.js></script>';
$html .= '<script type=text/javascript src=assets/bibtex/bib-publication-list.js></script>';
$html .= '<script type=text/javascript>';
$html .= '$(document).ready(function() {';
if (0 === strpos($tag->attr('bibtex'), 'http')) {
// starts with http
$lib = $tag->attr('bibtex');
}
else
{
$lib = url($path = '/'.$tag->attr('bibtex'));
}
$html .= 'bibtexify(\''.$lib.'\', \'pubTable\');';
$html .= '});';
$html .= '</script>';
$html .= '</div>';
return $html;
}
);
?>
which I changed to:
<?php
Kirby::plugin('test/bibtex', [
'tags' => [
'bibtex' => [
'html' => function($tag) {
$html = '<div>';
$html .= '<link rel=stylesheet href=assets/bibtex/bib-publication-list.css>';
$html .= '<div class=publications>';
$html .= '<table id=pubTable class=display>';
$html .= '</table>';
$html .= '</div>';
$html .= '<script type=text/javascript src=assets/bibtex/jquery-2.1.4.min.js></script>';
$html .= '<script type=text/javascript src=assets/bibtex/jquery.dataTables.min.js></script>';
$html .= '<script type=text/javascript src=assets/bibtex/BibTex-0.1.2.js></script>';
$html .= '<script type=text/javascript src=assets/bibtex/bib-publication-list.js></script>';
$html .= '<script type=text/javascript>';
$html .= '$(document).ready(function() {';
if (0 === strpos($tag->attr('bibtex'), 'http')) {
// starts with http
$lib = $tag->attr('bibtex');
}
else
{
$lib = url($path = '/'.$tag->attr('bibtex'));
}
$html .= 'bibtexify(\''.$lib.'\', \'pubTable\');';
$html .= '});';
$html .= '</script>';
$html .= '</div>';
return $html;
}
]
]
]);
?>
The dev console error is “Uncaught ReferenceError: array_values is not defined”.
Maybe anyone who could point me to the right direction or to a sample I can learn from?
Thanks,
Tim