Reputation: 13
With my very basic PHP knowledge I'm trying to make a module for Joomla V1.5. I am not quite into all the Joomla classes and methods but perhaps you can help me out.
What I'm trying to do is create a php loop which echo's all the article id's (and some html) from a certain category. Normally I would do this by calling on the content table from the Joomla db but to make the code a bit more tidy I want to use the Joomla classes for this. Can anyone point me the right direction which classes and methods to use for this?
Upvotes: 1
Views: 2600
Reputation: 969
There are no classes for handling the selection of the articles.
So it comes down to using a query and looping through the result set:
$catId = 59; // the category ID
$query = "SELECT * FROM #__content WHERE catid ='" . $catId . "'"; // prepare query
$db = &JFactory::getDBO(); // get database object
$db->setQuery($query); // apply query
$articles = $db->loadObjectList(); // execute query, return result list
foreach($articles as $article){ // loop through articles
echo 'ID:' . $article->id . ' Title: ' . $article->title;
}
Upvotes: 1