Get number of articles from a specific content category using Joomla functions -
i'm struggling number of articles specific category custom module? mind pointing me in correct direction function should use?
i've been using following:
$model = jmodellegacy::getinstance('articles', 'contentmodel'); $model->setstate('filter_fields.catid', 16); $articles = $model->getitems(); but following returned:
object(contentmodelarticles)[134] protected 'cache' => array empty protected 'context' => string 'com_content.articles' (length=20) protected 'filter_fields' => array 0 => string 'id' (length=2) 1 => string 'a.id' (length=4) 2 => string 'title' (length=5) 3 => string 'a.title' (length=7) 4 => string 'alias' (length=5) 5 => string 'a.alias' (length=7) 6 => string 'checked_out' (length=11) 7 => string 'a.checked_out' (length=13) 8 => string 'checked_out_time' (length=16) 9 => string 'a.checked_out_time' (length=18) 10 => string 'catid' (length=5) 11 => string 'a.catid' (length=7) 12 => string 'category_title' (length=14) 13 => string 'state' (length=5) 14 => string 'a.state' (length=7) 15 => string 'access' (length=6) 16 => string 'a.access' (length=8) 17 => string 'access_level' (length=12) 18 => string 'created' (length=7) 19 => string 'a.created' (length=9) 20 => string 'created_by' (length=10) 21 => string 'a.created_by' (length=12) 22 => string 'ordering' (length=8) 23 => string 'a.ordering' (length=10) 24 => string 'featured' (length=8) 25 => string 'a.featured' (length=10) 26 => string 'language' (length=8) 27 => string 'a.language' (length=10) 28 => string 'hits' (length=4) 29 => string 'a.hits' (length=6) 30 => string 'publish_up' (length=10) 31 => string 'a.publish_up' (length=12) 32 => string 'publish_down' (length=12) 33 => string 'a.publish_down' (length=14) 34 => string 'images' (length=6) 35 => string 'a.images' (length=8) 36 => string 'urls' (length=4) 37 => string 'a.urls' (length=6) protected 'query' => array empty protected '__state_set' => null protected '_db' => object(jdatabasemysqli)[15] public 'name' => string 'mysqli' (length=6) protected 'namequote' => string '`' (length=1) protected 'nulldate' => string '0000-00-00 00:00:00' (length=19) protected 'dbminimum' => string '5.0.4' (length=5) private '_database' (jdatabase) => string 'xxxx' (length=25) protected 'connection' => object(mysqli)[16] public 'affected_rows' => null public 'client_info' => null public 'client_version' => null public 'connect_errno' => null public 'connect_error' => null public 'errno' => null public 'error' => null public 'field_count' => null public 'host_info' => null public 'info' => null public 'insert_id' => null public 'server_info' => null public 'server_version' => null public 'sqlstate' => null public 'protocol_version' => null public 'thread_id' => null public 'warning_count' => null protected 'count' => int 0 protected 'cursor' => object(mysqli_result)[202] public 'current_field' => null public 'field_count' => null public 'lengths' => null public 'num_rows' => null public 'type' => null protected 'debug' => boolean false protected 'limit' => int 0 protected 'log' => array empty protected 'offset' => int 0 protected 'sql' => object(jdatabasequerymysqli)[258] protected 'db' => &object(jdatabasemysqli)[15] protected 'type' => string 'select' (length=6) protected 'element' => null protected 'select' => object(jdatabasequeryelement)[257] protected 'name' => string 'select' (length=6) protected 'elements' => array 0 => string 'm.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid' (length=80) protected 'glue' => string ',' (length=1) protected 'delete' => null protected 'update' => null protected 'insert' => null protected 'from' => object(jdatabasequeryelement)[259] protected 'name' => string 'from' (length=4) protected 'elements' => array 0 => string '#__modules m' (length=15) protected 'glue' => string ',' (length=1) protected 'join' => array 0 => object(jdatabasequeryelement)[260] protected 'name' => string 'left join' (length=9) protected 'elements' => array 0 => string '#__modules_menu mm on mm.moduleid = m.id' (length=43) protected 'glue' => string ',' (length=1) 1 => object(jdatabasequeryelement)[262] protected 'name' => string 'left join' (length=9) protected 'elements' => array 0 => string '#__extensions e on e.element = m.module , e.client_id = m.client_id' (length=72) protected 'glue' => string ',' (length=1) protected 'set' => null protected 'where' => object(jdatabasequeryelement)[261] protected 'name' => string 'where' (length=5) protected 'elements' => array 0 => string 'm.published = 1' (length=15) 1 => string 'e.enabled = 1' (length=13) 2 => string '(m.publish_up = '0000-00-00 00:00:00' or m.publish_up <= '2013-10-07 14:10:50')' (length=79) 3 => string '(m.publish_down = '0000-00-00 00:00:00' or m.publish_down >= '2013-10-07 14:10:50')' (length=83) 4 => string 'm.access in (1,1)' (length=17) 5 => string 'm.client_id = 0' (length=15) 6 => string '(mm.menuid = 113 or mm.menuid <= 0)' (length=35) protected 'glue' => string ' , ' (length=5) protected 'group' => null protected 'having' => null protected 'columns' => null protected 'values' => null protected 'order' => object(jdatabasequeryelement)[264] protected 'name' => string 'order by' (length=8) protected 'elements' => array 0 => string 'm.position, m.ordering' (length=22) protected 'glue' => string ',' (length=1) protected 'union' => null protected 'autoincrementfield' => null protected 'tableprefix' => string 'joomla_' (length=7) protected 'utf' => boolean true protected 'errornum' => int 0 protected 'errormsg' => string '' (length=0) protected 'hasquoted' => boolean false protected 'quoted' => array empty protected 'name' => string 'articles' (length=8) protected 'option' => string 'com_content' (length=11) protected 'state' => object(jobject)[279] protected '_errors' => array empty public 'filter_fields.catid' => int 16 protected 'event_clean_cache' => string 'oncontentcleancache' (length=19) protected '_errors' => array empty
i changed code following:
$model = jmodellegacy::getinstance('articles', 'contentmodel'); $model->setstate('filter.category_id', 16); $articles = $model->getitems(); $num_articles = count($articles);
Comments
Post a Comment