Reputation: 2166
In my extension, I've retrieved articles from the content
table like this:
.......
.......
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('id, catid, title, introtext, attribs);
$query->from('#__content');
$query->where('catid="'.$cid.'"');
$query->where('state="1"');
.......
.......
Here I can retrieve attribs
data for each article being retrieved.
Is there an easy way to retrieve article params from the global settings (is there some sort of static function in Joomla?) or do I need to manually retrieve the params
from the extensions
table?
Upvotes: 0
Views: 187
Reputation: 2494
You might want to use the JComponentHelper class to get the params of the component.
<?php
jimport( 'joomla.application.component.helper' );
$com_content_params = JComponentHelper::getParams('com_content');
To get the articles I wouldn't write the query myself as you do, but use the relevant JModel (JModelLegacy in Joomla 3) instance instead.
Something that would look like:
<?php
$model = JModel::getInstance('Articles', 'ContentModel');
$model->setState('filter.category_id', (int)$cid);
$articles = $model->getList();
Don't know if that specific code will work, but you certainly can do some research on Google about that. The spirit is there: use the classes provided by Joomla instead of pulling stuff directly from the DB. You'll gain in maintainability and code quality.
Upvotes: 3