簡體   English   中英

從旁邊顯示的模塊訪問Joomla 3.2文章標題

[英]Access Joomla 3.2 article title from the module displayed alongside

我正在寫一個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 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM