0

This are functions used in my module So am using it for displaying the articles with published state and with certain conditions.

class modArtbyauthorHelper

{



    function loadCbDetails(&$params)

    {

        $topid = JRequest::getInt('id');

        $db = JFactory :: getDBO();

        $query = "SELECT firstname, user_id, lastname, avatar, cb_category, cb_informationnew FROM #__comprofiler WHERE cb_category = ".$topid;

        $db->setQuery($query);

        $result = $db->loadObjectList();

        return $result;

    }

    function loadArticles(&$params)

    {

        $helper = new modArtbyauthorHelper();

        $result = $helper->loadCbDetails($params);

        $cb_userid = $result[0]->user_id; 
        $catid = $result[0]->cb_category; 

        $limit = $params->get('limit');

        $db = JFactory :: getDBO();

        $query = "SELECT title, id FROM #__content WHERE state=1 AND created_by = ".$cb_userid." AND catid <> ".$catid." ORDER BY created DESC LIMIT ".$limit; 

        $db->setQuery($query);

        $result = $db->loadObjectList();

        return $result;


    }



}

I Want to hide unpublished articles for it. But Not Able to find the exact condition required for it. So plz give your suggestions.

Durgesh Sonawane
  • 95
  • 1
  • 3
  • 11
  • Below link might help you not sure.. http://stackoverflow.com/questions/8777915/joomla-article-page-code-to-check-published-or-not – Faizul Hasan Oct 16 '12 at 05:48
  • But I Want to check the category is published or not. and if not i want to hide the article with unpublished category – Durgesh Sonawane Oct 16 '12 at 05:50

2 Answers2

0

Try archiving the unpublished articles.

Ajith
  • 305
  • 1
  • 3
  • 10
0

You should use use Joomla 1.6 model object and $model->setState('fileter.published', 1). I think you are getting all the results because of the request parameters.

This is a simplified version of what I use to get articles in Joomla >1.6

https://gist.github.com/3897436

Saul Martínez
  • 920
  • 13
  • 28
  • But in My case there are 2 articles with same name but different category. 1. It shows first category article correctly. For 2nd article the category is child category. Its parent category is published but child category is unpublished i want hide that 2nd article. – Durgesh Sonawane Oct 16 '12 at 05:57
  • See the code at line 22. You should have a parameter indicating whether child categories (published) are to be iterated, which is what the code does. – Saul Martínez Oct 16 '12 at 06:06
  • I just added a xml file just to show off the parameters involved. – Saul Martínez Oct 16 '12 at 06:13