Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • erickpaulino Friend
    #199896

    Hello,

    I am trying to add a new sorting option to the Latest News Module so I can use it with the JA Magz “focus” alternative layout. I want to be able to sort Featured Articles in the order I set on the Admin panel, DESCENDING.

    I am trying to edit the file modules/mod_articles_latest/helper.php which originally is:

    // Set ordering
    $order_map = array(
    'm_dsc' => 'a.modified DESC, a.created',
    'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END',
    'c_dsc' => 'a.created',
    'p_dsc' => 'a.publish_up',
    'random' => 'RAND()',

    I have added a last line:

    // Set ordering
    $order_map = array(
    'm_dsc' => 'a.modified DESC, a.created',
    'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END',
    'c_dsc' => 'a.created',
    'p_dsc' => 'a.publish_up',
    'random' => 'RAND()',
    'sort_order' => 'a.ordering',

    and added the respective option to the XML file. The problem is that “a.ordering” is not sorting the articles the way I want.

    Can you help me what should I use instead of “a.ordering” to sort the Featured Articles in the order I set on the Admin panel, DESCENDING?

    Thank you,

    Erick

    Adam M Moderator
    #543351

    Hi Erick,

    Could you please clarify a little bit so I can assist you better ? Provide a screenshot would help a lots.

    erickpaulino Friend
    #543475

    Hello,

    Sure, let me try to put it simpler. This is the Latest News Module, as you can see on JA Magz documentation:

    I has a pretty cool layout, which is called “JA Magz – Focus”:

    What I want to do is to sort the articles shown in this module not by date, but by “Featured articles order”. Unfortunately, this option is not available for the Latest News module:

    At first, I tried to do that by replacing the “Latest News module” by the “Articles Category Module”, which already have the sorting option I want. But I cannot use the “Focus” Alternative Layout with it.

    So, I believe there are two possible solutions for this:

    1. Add the filtering option I want to the Latest News module, as I have asked in my first message;
    2. Add the Focus Layout to the Articles Categories module. Maybe this is simpler, but by default this option is not available in the module manager.

    Hope this is better explained now…

    Thank you!

    Erick


    1. latestnews-fr1
    2. focus
    3. latest
    Adam M Moderator
    #543612

    Hi,

    You might want to try this :

    1. Open file root_folder/modules/mod_articles_latest/mod_articles_latest.xml and look for this code :

    <field
    name="ordering"
    type="list"
    default="published"
    label="MOD_LATEST_NEWS_FIELD_ORDERING_LABEL"
    description="MOD_LATEST_NEWS_FIELD_ORDERING_DESC">
    <option
    value="c_dsc">MOD_LATEST_NEWS_VALUE_RECENT_ADDED</option>
    <option
    value="m_dsc">MOD_LATEST_NEWS_VALUE_RECENT_MODIFIED</option>
    <option
    value="p_dsc">MOD_LATEST_NEWS_VALUE_RECENT_PUBLISHED</option>
    <option
    value="mc_dsc">MOD_LATEST_NEWS_VALUE_RECENT_TOUCHED</option>
    <option
    value="random">MOD_LATEST_NEWS_VALUE_RECENT_RAND</option>
    </field>

    then update as below :

    <field
    name="ordering"
    type="list"
    default="published"
    label="MOD_LATEST_NEWS_FIELD_ORDERING_LABEL"
    description="MOD_LATEST_NEWS_FIELD_ORDERING_DESC">
    <option
    value="fp_dsc">MOD_LATEST_NEWS_VALUE_ORDERINGFEATURED</option>
    <option
    value="c_dsc">MOD_LATEST_NEWS_VALUE_RECENT_ADDED</option>
    <option
    value="m_dsc">MOD_LATEST_NEWS_VALUE_RECENT_MODIFIED</option>
    <option
    value="p_dsc">MOD_LATEST_NEWS_VALUE_RECENT_PUBLISHED</option>
    <option
    value="mc_dsc">MOD_LATEST_NEWS_VALUE_RECENT_TOUCHED</option>
    <option
    value="random">MOD_LATEST_NEWS_VALUE_RECENT_RAND</option>
    </field>

    2. Then open file root_folder/modules/mod_articles_latest/helper.php and look for this code :

    // Set ordering
    $order_map = array(
    'm_dsc' => 'a.modified DESC, a.created',
    'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END',
    'c_dsc' => 'a.created',
    'p_dsc' => 'a.publish_up',
    'random' => 'RAND()',
    );

    and update as below :

    // Set ordering
    $order_map = array(
    'm_dsc' => 'a.modified DESC, a.created',
    'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END',
    'c_dsc' => 'a.created',
    'fp_dsc' => 'fp.ordering',
    'p_dsc' => 'a.publish_up',
    'random' => 'RAND()',
    );

    erickpaulino Friend
    #543930

    Thank you, I’ll try it soon and I’ll let you know.

    erickpaulino Friend
    #544075

    Hello,

    It didn’t work. I also tried

    'fp_dsc' => 'a.featured DESC, fp.ordering',

    as suggested here:
    http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=28171

    but it didn’t work either. It did change the order, but in a strange and unpredictable manner.

    Any other suggestion?

    Thank you,

    Erick

    Adam M Moderator
    #544108

    Hi Erick,

    Please make sure that you will have to navigate to Admin >>> Extensions >>> Module Manager >>> choose Latest News module >>> in Order option >>> choose new filter then Save.

    erickpaulino Friend
    #544158

    Hello,

    Yes, I’m doing this. I’m also setting the filter to display only featured articles. I believe it’s a matter of finding the right code to replace the ‘fp_dsc’ => ‘fp.ordering’

    Any suggestions?

    Thank you

    Adam M Moderator
    #544425

    Hi,

    Please hold on a little bit while I’m checking this matter for you.

    Adam M Moderator
    #544735

    Hi,

    Could you please provide your site url and temporary back-end account via private reply so I can take a closer look ?

    erickpaulino Friend
    #546594

    Hello Adam M,

    I have just sent you a message.

    Thank you,

    Erick

    erickpaulino Friend
    #546604

    Hello Adam M,

    Me again. I have just found the solution. Under templates/ja_magz/html/mod_articles_latest/focus.php

    there is a code to force articles to be ordered by hits. I have commented out the lines below


    //sort those latest article by hits
    //$compare = create_function('$a, $b', ' if ($a->hits == $b->hits) { return 0; } return ($a->hits < $b->hits) ? 1 : -1; ');
    //uasort($list, $compare);

    And it is now working.

    Thank you!

    Adam M Moderator
    #546691

    Hi,

    Glad to hear that you managed to sort it out. If you still have any question, don’t hesitate to let me know.

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

This topic contains 13 replies, has 2 voices, and was last updated by  Adam M 10 years, 3 months ago.

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