从旁边显示的模块中访问Joomla 3.2文章标题
-
23-12-2019 - |
题
我正在写一个Joomla!我需要显示当前文章标题的模块。
我已经在stackoverflow上找到了此代码:
<?php
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
echo $article->get("title");
?>
.
虽然它有效,但它使用弃用类jRequest,因为它来自Joomla 1.7,我使用3.2.2。有人可以告诉我如何重写它与Joomla 3.2有效吗?
解决方案
您可以使用以下代码使用最新的编码标准:
$input = JFactory::getApplication()->input;
$id = $input->getInt('id'); //get the article ID
$article = JTable::getInstance('content');
$article->load($id);
echo $article->get('title'); // display the article title
.
希望这有助于
不隶属于 StackOverflow