Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • ja4saka Friend
    #200389

    Hi,

    After some modification, we update and redesign the layout and functions from Magz theme here:
    http://sjoomla3.abouthair.tw/magz/

    We modified those files to adapt masonry list:
    /templates/ja_magz/html/com_content/featured/default.php
    /templates/ja_magz/html/com_content/featured/default_item.php

    We want to make the featured articles listed on main page sorting by date (desc) or random.
    Sort by date is a default behavior, and we try to hack the code by adding “RAND()” into sql statement, but we are not lucky enough, can’t find the key file to complete this mission.

    We find an article about sorting random here this forum, still not work, any advice is welcome and we appreciate any replies about how to add this feature, thanks in advance.

    Saguaros Moderator
    #545499

    Hi

    In the home page of this JA Magz template, we use menu item type of ‘Featured articles‘ and it will display due to the settings of home menu item in your site. These are some hints to add random option:
    – Add a ‘Random‘ option in the ‘Article order’ parameter in Layout settings of this menu item via file: /root/components/com_content/views/featured/tmpl/default.xml, look for this field:


    <field name="orderby_sec" type="list" description="JGLOBAL_ARTICLE_ORDER_DESC" label="JGLOBAL_ARTICLE_ORDER_LABEL" >
    <option value="">JGLOBAL_USE_GLOBAL</option>
    <option value="front">COM_CONTENT_FEATURED_ORDER</option>
    <option value="rdate">JGLOBAL_MOST_RECENT_FIRST</option>
    <option value="date">JGLOBAL_OLDEST_FIRST</option>
    <option value="alpha">JGLOBAL_TITLE_ALPHABETICAL</option>
    <option value="ralpha">JGLOBAL_TITLE_REVERSE_ALPHABETICAL</option>
    <option value="author">JGLOBAL_AUTHOR_ALPHABETICAL</option>
    <option value="rauthor">JGLOBAL_AUTHOR_REVERSE_ALPHABETICAL</option>
    <option value="hits">JGLOBAL_MOST_HITS</option>
    <option value="rhits">JGLOBAL_LEAST_HITS</option>
    <option value="order">JGLOBAL_ORDERING</option>
    <option vlaue="random">Random</option>
    </field>

    – Alter the query: /root/components/com_content/helpers/query.php, you will need to add a random option like so:

    case 'random' :
    $orderby = 'RAND()';
    break;

    Please note that this customization requires hack in code of core Joomla so it’s best if you also raise the same thread into Joomla forum for better answer there.

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

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

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