カウントダウンタイマーを追加できる記事用のJoomlaアドインを作成したいと思います。私は、例えばショートコード[countdowntimer date = "23-9-2017" time = "13:42"]
を使って実行できるようにしたいと考えています。ショートコードにパラメータを追加してモジュールに移動するにはどうすればよいかわかりません。 [countdowntimer]
を私のカウンターに交換しました。Joomla 3.x.x Shortcodeプラグインとモジュールでエラーが発生しました
<?php
defined('_JEXEC') or die();
class plgContentShortcode extends JPlugin
{
protected $autoloadLanguage = true;
function onContentPrepare ($context, $article, $params, $limitstart)
{
// preg_match("/([[]countdowntimer(.*)[]])/", $article->text, $tmp, PREG_OFFSET_CAPTURE);
// I'm trying to extract parameters in this way
// preg_match("/date=\"([0-9-]+)\"/", $tmp[2][0], $return_tmp['date'], PREG_OFFSET_CAPTURE); //date
// preg_match("/time=\"([0-9:]+)\"/", $tmp[2][0], $return_tmp['time'], PREG_OFFSET_CAPTURE); // time
$article->text = preg_replace('/([[]countdowntimer(.*)[]])/', '{loadmodule mod_countdowntimer}', $article->text);
return true;
}
}
?>
あなたが問題を述べたことをちょうど見ました。申し訳ありませんが、それを高速で読む:-) –