Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • Josh Friend
    #206256

    Hi there,

    I want the Joomla article categories (not articles) to follow the order as in the Category Manager instead of Ascending or Descending. May I know how to modify the code?

    Thank you

    jooservices Friend
    #570074

    <em>@mredwan 472741 wrote:</em><blockquote>Hi there,

    I want the Joomla article categories (not articles) to follow the order as in the Category Manager instead of Ascending or Descending. May I know how to modify the code?

    Thank you</blockquote>

    Hi there
    May i know which view you are mentioned ? At frontend view=categories or in backend ?
    Have you checked with Joomla! document about configuration ?

    Thank you,
    Viet Vu

    jooservices Friend
    #735146

    <em>@mredwan 472741 wrote:</em><blockquote>Hi there,

    I want the Joomla article categories (not articles) to follow the order as in the Category Manager instead of Ascending or Descending. May I know how to modify the code?

    Thank you</blockquote>

    Hi there
    May i know which view you are mentioned ? At frontend view=categories or in backend ?
    Have you checked with Joomla! document about configuration ?

    Thank you,
    Viet Vu

    Josh Friend
    #570080

    Hi Viet Vu,

    My question is similar to
    http://www.joomlart.com/forums/topic/ja-news-2-order-categories/

    That thread replies to News2… I’m asking about JA News Pro

    jooservices Friend
    #570089

    Hi there
    It’s require core hacking.
    Please check adapter file ( which one you are using ). and adding

    $query->order(< your own ordering here >);

    Thank you,
    Viet Vu

    Josh Friend
    #570097

    From website/modules/mod_janewspro/helpers/adapter/content.php ? (for Joomla article)

    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->select(‘c.`id`’);
    $query->from(‘#__categories AS c’);
    $query->where(‘c.`id` IN (‘.rtrim($lwhere, ‘, ‘).’)’);
    $query->where(‘c.`language` IN (”.$lang.”, ‘*’)’);
    $db->setQuery($query);
    $items = $db->loadRowList();
    $it=array();
    foreach ($items AS $item) {
    $it[] = $item[0];
    }
    $arr_cats = $it;

    I don’t want Ascending or Descending… I want it to follow the ORDER of the categories in the Category Manager.

    So what do I put inside?

    $query->order(< your own ordering here >);

    jooservices Friend
    #570098

    <em>@mredwan 472772 wrote:</em><blockquote>From website/modules/mod_janewspro/helpers/adapter/content.php ? (for Joomla article)

    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->select(‘c.`id`’);
    $query->from(‘#__categories AS c’);
    $query->where(‘c.`id` IN (‘.rtrim($lwhere, ‘, ‘).’)’);
    $query->where(‘c.`language` IN (”.$lang.”, ‘*’)’);
    $db->setQuery($query);
    $items = $db->loadRowList();
    $it=array();
    foreach ($items AS $item) {
    $it[] = $item[0];
    }
    $arr_cats = $it;

    I don’t want Ascending or Descending… I want it to follow the ORDER of the categories in the Category Manager.

    So what do I put inside?

    $query->order(< your own ordering here >);
    </blockquote>

    Hi there
    If you can’t work on it. Please provide FTP access. I’ll help you update it.

    But please note it’s core hacking. You’ll face with your risky and lose your modified with updating in future

    Thank you,
    Viet Vu

    Josh Friend
    #570100

    Yes, I know it’s core hacking on the News Pro module. Unfortunately I’m working on localhost. All I’m asking is… what do I put inside

    $query->order(< your own ordering here >);

    c.ordering? as I can see from the _categories table, there is no ‘ordering’ column (field)

    jooservices Friend
    #570104

    <em>@mredwan 472776 wrote:</em><blockquote>Yes, I know it’s core hacking on the News Pro module. Unfortunately I’m working on localhost. All I’m asking is… what do I put inside

    $query->order(< your own ordering here >);

    c.ordering? as I can see from the _categories table, there is no ‘ordering’ column (field)</blockquote>

    Hi there
    It’s Joomla logic about ordering. Because you are doing core modify / customize. Please reference Joomla.

    For sample in backend com_categories if we echo query when doing sorting by Order we’ll have


    SELECT a.id, a.title, a.alias, a.note, a.published, a.access, a.checked_out, a.checked_out_time, a.created_user_id, a.path, a.parent_id, a.level, a.lft, a.rgt, a.language,l.title AS language_title,uc.name AS editor,ag.title AS access_level,ua.name AS author_name
    FROM #__categories AS a
    LEFT JOIN `#__languages` AS l ON l.lang_code = a.language
    LEFT JOIN #__users AS uc ON uc.id=a.checked_out
    LEFT JOIN #__viewlevels AS ag ON ag.id = a.access
    LEFT JOIN #__users AS ua ON ua.id = a.created_user_id
    WHERE a.extension = 'com_content' AND (a.published IN (0, 1))
    ORDER BY a.lft DESC

    Now back with this module, you can apply your own ordering by follow above
    c.lft DESC ( or ASC as your needed )

    Thank you,
    Viet Vu

    jooservices Friend
    #570105

    Hi there
    Here is document about this ordering logic

    http://www.sitepoint.com/hierarchical-data-database-2/

    Thank you,
    Viet Vu

    Josh Friend
    #570131

    Thank you for your lengthy explanation but it’s still not what I want.

    Let me explain another way… For the module, I have 4 categories all at the same level. Their catsid are
    “375”,”376″,”377″,”378″

    So if it’s ASC it will be “375”,”376″,”377″,”378″

    If it’s DESC it will be “378”,”377″,”376″,”375″

    But what I want is this order
    “375”,”377″,”376″,”378″

    I don’t mind hard-coding in the content.php file. How do I do this?

    Do I have to modify or get rid of the following snippet i.e. $arr_cats?

    $categoriesSortDir = $params->get(‘cat_ordering’, ‘asc’);
    if($categoriesSortDir == ‘desc’){
    $arr_cats = array_reverse($arr_cats);
    }

    $lang = JFactory::getLanguage()->getTag();
    $lwhere = ”;
    foreach ($arr_cats AS $v) {
    if ($v != ”) $lwhere .= $v.’, ‘;
    }

    jooservices Friend
    #570161

    <em>@mredwan 472812 wrote:</em><blockquote>Thank you for your lengthy explanation but it’s still not what I want.

    Let me explain another way… For the module, I have 4 categories all at the same level. Their catsid are
    “375”,”376″,”377″,”378″

    So if it’s ASC it will be “375”,”376″,”377″,”378″

    If it’s DESC it will be “378”,”377″,”376″,”375″

    But what I want is this order
    “375”,”377″,”376″,”378″

    I don’t mind hard-coding in the content.php file. How do I do this?

    Do I have to modify or get rid of the following snippet i.e. $arr_cats?

    $categoriesSortDir = $params->get(‘cat_ordering’, ‘asc’);
    if($categoriesSortDir == ‘desc’){
    $arr_cats = array_reverse($arr_cats);
    }

    $lang = JFactory::getLanguage()->getTag();
    $lwhere = ”;
    foreach ($arr_cats AS $v) {
    if ($v != ”) $lwhere .= $v.’, ‘;
    }
    </blockquote>

    Hi there
    # You are trying to hard to category order or follow your backend category ordering ? That’s confusing me.
    Prev code you can use for backend ordering.
    # But if you want to apply your own thing than after queried . You can do foreach again to rearrange it.

    If you can’t work on it. Please consider ask for custom work with 3rd developer.

    Thank you,
    Viet Vu

    Josh Friend
    #570233

    Thank you Viet Vu for helping… I finally got it to work!

    Josh Friend
    #735305

    Thank you Viet Vu for helping… I finally got it to work!

    jooservices Friend
    #570234

    Glad to hear that

    Thank you,
    Viet Vu

Viewing 15 posts - 1 through 15 (of 16 total)

This topic contains 16 replies, has 2 voices, and was last updated by  jooservices 9 years, 6 months ago.

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