zor*_*rza 5 php joomla joomla-module joomla3.0
我正在写一个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");
?>
Run Code Online (Sandbox Code Playgroud)
虽然它有效,但它使用了弃用的类JRequest,因为它来自Joomla 1.7而我使用的是3.2.2.有人能告诉我如何重写它以使Joomla 3.2有效吗?
Lod*_*der 14
您可以使用以下使用最新编码标准的代码:
$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
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助