user863551
user863551

Reputation:

Pulling only the title and body of an article (Joomla)

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.

Upvotes: 1

Views: 2986

Answers (2)

Sehrish Malik
Sehrish Malik

Reputation: 1

                    $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");

Upvotes: 0

Shaz
Shaz

Reputation: 2647

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
}

Upvotes: 6

Related Questions