我正在写一个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
.

希望这有助于

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top