Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • jedileong Friend
    #163580

    Hi!
    JA News2 show all the category by order/date only.
    I have 10 category, only the first 3 category appear at the News2, the rest of the 7 category will never appear on the front page.
    I want these category appear randomly, which it’ll display 3 randomly on everytime.
    How can I make it like this?
    Please help-THX

    Sorry for my english


    1. a
    thangnn1510 Friend
    #390054

    Hi Jedileong!

    You could do it yourself by some small customizations (I’ll be done in code). Please go to modulesmod_janews2helper.php and find this code:

    $query = "SELECT `id`, `title`, `description`, CASE WHEN CHAR_LENGTH(`alias`) THEN CONCAT_WS(":", `id`, `alias`) ELSE `id` END as `slug` FROM `#__categories` s WHERE published = 1 and section=" . ( int ) $sid . $where .' ORDER BY s.ordering';

    change to:

    $query = "SELECT `id`, `title`, `description`, CASE WHEN CHAR_LENGTH(`alias`) THEN CONCAT_WS(":", `id`, `alias`) ELSE `id` END as `slug` FROM `#__categories` s WHERE published = 1 and section=" . ( int ) $sid . $where .' ORDER BY RAND()';

    That will help.

    jedileong Friend
    #390134

    Thank you!!
    but there come another issue, i have 4 section in the JA News2, i only want the first 2 section to appear randomly, another 2 section order by default. How can i make like this? The first 2 section ID is 14 & 13, another 2 section ID is 12 & 8.

    Many thanks for your assistance!

    thangnn1510 Friend
    #390505

    You could change the code I suggested Above to

    if(($sid==13)||($sid==14)){
    $query = "SELECT `id`, `title`, `description`, CASE WHEN CHAR_LENGTH(`alias`) THEN CONCAT_WS(":", `id`, `alias`) ELSE `id` END as `slug` FROM `#__categories` s WHERE published = 1 and section=" . ( int ) $sid . $where .' ORDER BY RAND()';
    }else{
    $query = "SELECT `id`, `title`, `description`, CASE WHEN CHAR_LENGTH(`alias`) THEN CONCAT_WS(":", `id`, `alias`) ELSE `id` END as `slug` FROM `#__categories` s WHERE published = 1 and section=" . ( int ) $sid . $where .' ORDER BY s.ordering';
    }

    That will help you in this case.

    jedileong Friend
    #391887

    thanks thangnn! it work perfectly!

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

This topic contains 5 replies, has 2 voices, and was last updated by  jedileong 13 years, 6 months ago.

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