2012-03-26 22 views

回答

7

我剛剛測試此代碼,它似乎對的Joomla 2.5.3工作:

$option = JRequest::getCmd('option'); 
$view = JRequest::getCmd('view'); 
if ($option=="com_content" && $view=="article") { 
    $ids = explode(':',JRequest::getString('id')); 
    $article_id = $ids[0]; 
    $article =& JTable::getInstance("content"); 
    $article->load($article_id); 
    echo $article->get("title"); 
    echo $article->get("introtext"); // and/or fulltext 
} 
+0

謝謝您的答覆。我已經把這是我的代碼,但它似乎沒有返回任何東西。有任何想法嗎? – MrDKOz 2012-03-26 19:48:00

+0

你使用什麼樣的視圖?單篇文章,博客,特色文章...? – Shaz 2012-03-26 19:50:45

+0

單篇文章。 – MrDKOz 2012-03-26 19:55:54

0
    $catId = 80; 
        $query = "SELECT * FROM #__content WHERE catid ='" . $catId . "'"; 
        $db = &JFactory::getDBO(); 
        $db->setQuery($query); 
        $articles = $db->loadObjectList(); 
        foreach($articles as $article){ 


        $article_id=$article->id; 
        $article_title=$article->title; 

        $article_content=$article->get("introtext"); 
+0

這個答案是不正確的,你設置類別ID爲80和OP沒有說任何關於這一點。如果$ articles是'NULL',或多或少這個代碼將通過日誌上的警告 – 2013-03-13 13:21:31

相關問題