test
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • sir2001 Friend
    #174734

    I have noticed that when I select more than one category, articles are ordered first by category and in second place by date, but if I set “Categories Selection” to “All categories”, articles are properly ordered by date whatever it category.

    Is there any way to display articles in Content Slider module ordered by date when multiple categories are selected?

    Sherlock Friend
    #443966

    Hi Sir2001,

    I think it’s a little bit difficulties to get the articles order by that way, let me know your joomla version and I may have a further checking on this.

    sir2001 Friend
    #444293

    Hi Dat,

    Currently, I am working with Joomla 2.5.

    Regards

    Sherlock Friend
    #444443

    Hi Sir2001,

    You can try as following to re-order the articles after they were got out from database
    Open the file of modulesmod_jacontentsliderhelper.php look for this code
    [PHP] if (!empty($catid) && intval($catid[0]) > 0) {
    for($i=0; $i<count($catid); $i++){
    if(intval($catid[$i]) > 0){
    $model->setState(‘filter.category_id’, $catid[$i]);
    $model->setState(‘list.limit’, $params->get(‘maxitems’, 10));
    $data = array_merge($data, $model->getItems());
    }
    }
    }else{
    //$model->setState(‘list.limit’, $params->get(‘maxitems’, 10));
    $data = array_merge($data, $model->getItems());
    }[/PHP]

    And add below it this code
    [PHP] for($k = (count($data)-1);$k >= 0;$k–){
    for($j = 0;$j <= $k-1;$j++){
    if(strtotime($data[$j]->created) > strtotime($data[$j+1]->created)){
    $temp = $data[$j];
    $data[$j] = $data[$j+1];
    $data[$j+1] = $temp;
    }
    }
    }[/PHP]

    I hope that would help !

    sir2001 Friend
    #444512

    It works like a charm!!! Thx a lot

    I have only modified provided code
    [PHP]if(strtotime($data[$j]->created) > strtotime($data[$j+1]->created))[/PHP]
    with this code
    [PHP]if(strtotime($data[$j]->created) < strtotime($data[$j+1]->created))[/PHP]
    in order to put newer elements in first place.

    Again, thanks for your support.

Viewing 5 posts - 1 through 5 (of 5 total)

This topic contains 5 replies, has 2 voices, and was last updated by  sir2001 12 years, 9 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum