-
AuthorPosts
-
March 7, 2012 at 9:47 pm #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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
March 16, 2012 at 10:37 am #443966Hi 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.
March 18, 2012 at 9:46 am #444293Hi Dat,
Currently, I am working with Joomla 2.5.
Regards
Sherlock FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
March 19, 2012 at 3:29 am #444443Hi 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 !
1 user says Thank You to Sherlock for this useful post
March 19, 2012 at 12:26 pm #444512It 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.
-
AuthorPosts
This topic contains 5 replies, has 2 voices, and was last updated by sir2001 12 years, 8 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum