开发者

Place certain article anywhere in joomla template

开发者 https://www.devze.com 2023-03-18 09:23 出处:网络
Is it possible in Joomla to place a certain article in a template, addition开发者_运维问答ally to the normal content? I want the article to show up on every page.You can simply take it from the databs

Is it possible in Joomla to place a certain article in a template, addition开发者_运维问答ally to the normal content? I want the article to show up on every page.


You can simply take it from the databse and print its content. In the template, where you want to show the article, write this:

$id=/*Id of the article to show*/;
$db=&JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id=$id");
$item=$db->loadObject();
echo $item->introtext;

UPDATE: ENABLE PLUGINS

I can't find where i've used that code and i can't copy-paste it, so i try to write it again by looking at the view.html.php of the com_content:

JPluginHelper::importPlugin('content');
$dispatcher =& JDispatcher::getInstance();
$params = &$mainframe->getParams();
$dispatcher->trigger('onPrepareContent', array (&$item, &$params, 0));
//The last line triggers the onPrepareContent event, so if it does not work maybe you need other events, so try with onAfterDisplayTitle, onBeforeDisplayContent or onAfterDisplayContent


Have you seen this? http://extensions.joomla.org/extensions/news-display/content-embed/7528

It allows you to place any article as a module on your Joomla site. And with modules you can have them displayed site wide.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号