1

I have inserted the following line into my Joomla template:

<jdoc:include type="component" />

This will bring across the whole post, including the title of the article. How can I bring the featured article title across seperate to it's body/content for styling purposes?

Thank you.

2 Answers2

6

I just tested this code and it seems to work on 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
}
Shaz
  • 2,647
  • 2
  • 35
  • 45
  • Thank you for your response. I have put this is my code, however it doesn't seem to return anything. Any ideas? –  Mar 26 '12 at 19:48
  • What kind of view are you using ? single article, blog, featured articles... ? – Shaz Mar 26 '12 at 19:50
  • I verified I'm working on 2.5.3 , I'm testing it with the beez_20 template, could you echo $option and $view to see if you get the expected results (com_content and article) ? – Shaz Mar 26 '12 at 20:09
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");
  • This answer isn't correct, you set the category ID to 80 and the OP didn't say anything about that. More or less this code will through warning on the logs if $articles was `NULL` – Ahmad Alfy Mar 13 '13 at 13:21