在我的 joomla 中添加简码
Add shortcode in my joomla
我想像在 wordpress 中那样在 joomla3 模板中添加 php 简码 (<?php echo do_shortcode( '[shortcode_id="1"]' ) ?>
)。
有什么办法吗?请帮助我。
您可以使用 DirectPHP,这是一个允许直接在 Joomla 内容页面中嵌入 PHP 命令的插件!
如果您不想使用任何扩展,您可以使用此代码(对于 Joomla 3.x):
$params = new JObject;
$article = new stdClass;
$article->text = '------> Write/Assign here the text with shortcodes <-----';
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array('text', &$article, &$params, 0));
echo $article->text;
我想像在 wordpress 中那样在 joomla3 模板中添加 php 简码 (<?php echo do_shortcode( '[shortcode_id="1"]' ) ?>
)。
有什么办法吗?请帮助我。
您可以使用 DirectPHP,这是一个允许直接在 Joomla 内容页面中嵌入 PHP 命令的插件!
如果您不想使用任何扩展,您可以使用此代码(对于 Joomla 3.x):
$params = new JObject;
$article = new stdClass;
$article->text = '------> Write/Assign here the text with shortcodes <-----';
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array('text', &$article, &$params, 0));
echo $article->text;