Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • Henning Friend
    #198498

    Hi Guys,

    First off, I’m using the Portfolio Layout as an events calendar. Thus the articles’ created date is the day on which the event will appear, I simply wish to sort these articles so that the most recent or upcoming events are first.

    I have double checked the dates on each article so the created date is configured correctly, all of them are in 2014 as well. On the Menu on which these articles should appear I have set the blog layout as mentioned below;

    Category Order; Use Global
    Article Order; Most Recent First
    Date for Ordering; Created (The day on which the event occurs.)

    I have also cleared the website’s cache as well as my browser’s cache but the articles are still in no particular order. It’s a bit mixed up; The typical order is of these events are displayed as follow; 14 December, 21 Sept, 14 June, 30 November etc.

    Please advise.

    kind Regards,
    Henning

    Ninja Lead Moderator
    #538011

    Just for better clarification, please include screenshot to illustrate the issue, I will help to check further.

    Henning Friend
    #538059

    Hi,

    Thanks for the feedback. Please find attached the screenshot of the current layout. You’ll notice that an event occuring in December is actually in front of an event occuring in June, the filtering is completely random.

    Regards,
    Henning


    1. Events
    Henning Friend
    #538318

    Hi Guys,

    Any progress or advise on this topic?

    Regards,
    Henning

    Ninja Lead Moderator
    #538341

    HI Henning,

    I could not see the option to set ordering on this module but you can try to my customize about on this module

    Open templates/ja_sugite/html/mod_articles_categories/portfolio_items.php file

    Change

    defined('_JEXEC') or die;

    To

    defined('_JEXEC') or die;
    function compare_create_date($a, $b) {
    if($a->created_time == $b->created_time) {
    return 0 ;
    }
    return ($a->created_time > $b->created_time) ? -1 : 1;
    }
    usort($list, 'compare_create_date');

    It will help you to change the ordering via created_time of article

    Let me know if it helps

    Regards

    Henning Friend
    #538368

    Hi,

    I have changed the portfolio_items.php located in ‘templates/ja_sugite/html/mod_articles_categories/’ and it seems that the articles are still in no particular order.

    The code in the portfolio_items.php is as follow;

    defined('_JEXEC') or die;
    function compare_create_date($a, $b) {
    if($a->created_time == $b->created_time) {
    return 0 ;
    }
    return ($a->created_time > $b->created_time) ? -1 : 1;
    }
    usort($list, 'compare_create_date');
    foreach ($list as $item) :

    ?>
    <li <?php if ($_SERVER['PHP_SELF'] == JRoute::_(ContentHelperRoute::getCategoryRoute($item->id))) echo ' class="active"';?>> <?php $levelup=$item->level-$startLevel -1; ?>
    <a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($item->id)); ?>">
    <?php echo $item->title;?>
    </a>

    <?php
    if($params->get('show_description', 0))
    {
    echo JHtml::_('content.prepare', $item->description, $item->getParams(), 'mod_articles_categories.content');
    }
    if($params->get('show_children', 0) && (($params->get('maxlevel', 0) == 0) || ($params->get('maxlevel') >= ($item->level - $startLevel))) && count($item->getChildren()))
    {

    echo '<ul>';
    $temp = $list;
    $list = $item->getChildren();
    require JModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default').'_items');
    $list = $temp;
    echo '</ul>';
    }
    ?>
    </li>
    <?php endforeach; ?>

    Please Advise.

    Regards,
    Henning

    Henning Friend
    #538457

    Hi Guys,

    Any ideas or suggestions, I’m still battling to filter these articles according to the created date. I have made changes to the code mentioned in the previous post but still no fix.

    Regards,
    Henning

    Ninja Lead Moderator
    #538471

    Hi Henning,

    You can try to do this again

    Open templates/ja_sugite/html/com_content/category/portfolio.php file

    Change

    <?php if (!empty($this->intro_items)) : ?>

    To


    <?php if (!empty($this->intro_items)) :
    function compare_create_date($a, $b) {
    if($a->created == $b->created) {
    return 0 ;
    }
    return ($a->created > $b->created) ? -1 : 1;
    }
    usort($this->intro_items, 'compare_create_date');
    ?>

    Let me know the result

    Regards

    Henning Friend
    #538506

    Hi,

    I have edited the code on portfolio.php and after refresh the page is blank (I have attached a Screenshot) with only the categories visible.

    The Code for portfolio.php is as follow;

    defined('_JEXEC') or die;

    JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
    JHtml::addIncludePath(T3_PATH.'/html/com_content');
    JHtml::addIncludePath(dirname(dirname(__FILE__)));
    JHtml::_('behavior.caption');
    //register the helper class
    JLoader::register('SugiteHelper', T3_TEMPLATE_PATH . '/templateHelper.php');
    //template params
    $tplparams = JFactory::getApplication()->getTemplate(true)->params;
    //Load grid items
    SugiteHelper::loadGridItems();
    ?>

    <div class="ja-masonry-wrap">
    <?php if ($this->params->get('show_page_heading', 1)) : ?>
    <div class="page-header clearfix">
    <h1 class="page-title"> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
    </div>
    <?php endif; ?>

    <?php if ($this->params->get('show_category_title', 1) or $this->params->get('page_subheading')) : ?>
    <div class="page-subheader clearfix">
    <h2 class="page-subtitle"><?php echo $this->escape($this->params->get('page_subheading')); ?>
    <?php if ($this->params->get('show_category_title')) : ?>
    <small class="subheading-category"><?php echo $this->category->title;?></small>
    <?php endif; ?>
    </h2>
    </div>
    <?php endif; ?>

    <?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
    <div class="category-desc clearfix">
    <?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
    <img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
    <?php endif; ?>
    <?php if ($this->params->get('show_description') && $this->category->description) : ?>
    <?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?>
    <?php endif; ?>
    </div>
    <?php endif; ?>
    <!-- Load Modules with position "portfolio-menu" -->
    <?php if(SugiteHelper::loadmodules('portfolio-menu','T3xhtml')): ?>
    <div class="inset">
    <?php echo SugiteHelper::loadmodules('portfolio-menu','T3xhtml'); ?>
    </div>
    <?php endif;?>
    <!-- End load -->
    <div class="grid blog<?php echo $this->pageclass_sfx;?>" id="grid">

    <?php if ($this->params->get('show_tags', 1) && !empty($this->category->tags->itemTags)) :
    $this->category->tagLayout = new JLayoutFile('joomla.content.tags');
    echo $this->category->tagLayout->render($this->category->tags->itemTags);
    endif; ?>

    <?php if (empty($this->lead_items) && empty($this->link_items) && empty($this->intro_items)) :
    if ($this->params->get('show_no_articles', 1)) : ?>
    <p><?php echo JText::_('COM_CONTENT_NO_ARTICLES'); ?></p>
    <?php endif; ?>
    <?php endif; ?>

    <?php $leadingcount = 0; ?>
    <?php if (!empty($this->lead_items)) : ?>
    <?php foreach ($this->lead_items as &$item) : ?>
    <?php
    $this->item = &$item;
    echo $this->loadTemplate('item');
    ?>
    <?php $leadingcount++; ?>
    <?php endforeach; ?>
    <?php endif; ?>

    <?php
    $introcount = (count($this->intro_items));
    $counter = 0;
    ?>

    <?php if (!empty($this->intro_items)) :function compare_create_date($a, $b) {
    if($a->created == $b->created) {
    return 0 ;
    }
    return ($a->created > $b->created) ? -1 : 1;
    }
    usort($this->intro_items, 'compare_create_date'); ?>
    <?php foreach ($this->intro_items as $key => &$item) : ?>
    <?php $rowcount = ((int) $counter % (int) $this->columns) + 1; ?>
    <?php
    $this->item = &$item;
    echo $this->loadTemplate('item');
    ?>
    <?php $counter++; ?>

    <?php endforeach; ?>
    <?php endif; ?>

    <?php if ($this->params->get('show_pagination') == 3 && $this->pagination->get('pages.total') > 1) : ?>
    <nav id="page-nav" class="pagination">
    <?php
    $urlparams = '';
    if (!empty($this->pagination->_additionalUrlParams)){
    foreach ($this->pagination->_additionalUrlParams as $key => $value) {
    $urlparams .= '&' . $key . '=' . $value;
    }
    }

    $next = $this->pagination->limitstart + $this->pagination->limit;
    $nextlink = JRoute::_($urlparams . '&' . $this->pagination->prefix . 'limitstart=' . $next);
    ?>
    <a id="page-next-link" href="<?php echo $nextlink ?>" data-limit="<?php echo $this->pagination->limit; ?>" data-start="<?php echo $this->pagination->limitstart ?>" data-page-total="<?php echo ceil($this->pagination->total / $this->pagination->limit);?>" data-total="<?php echo $this->pagination->total;?>"></a>
    </nav>
    <?php endif; ?>
    </div>
    <?php
    //Override pagination
    if ($this->params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2 && $this->pagination->get('pages.total') > 1) || $this->params->def('show_pagination', 2) == 3) : ?>
    <?php if ($this->params->def('show_pagination', 2) == 3) : ?>
    <?php if($this->pagination->get('pages.total') > 1) :?>
    <div id="infinity-next" class="btn btn-primary btn-block hidden"><?php echo JText::_('TPL_INFINITY_NEXT')?></div>
    <?php else:?>
    <div id="infinity-next" class="btn btn-primary btn-block disabled"><?php echo JText::_('TPL_JSLANG_FINISHEDMSG');?></div>
    <?php endif;?>
    <?php else : ?>
    <div class="pagination">
    <?php if ($this->params->def('show_pagination_results', 1)) : ?>
    <p class="counter pull-right">
    <?php echo $this->pagination->getPagesCounter(); ?>
    </p>
    <?php endif; ?>
    <?php echo $this->pagination->getPagesLinks(); ?>
    </div>
    <?php endif; ?>
    <?php endif; ?>
    </div>

    Any suggestions? I’m really concerned about the articles not filtering according to the parameters I’ve set. Thanks for the help, but still not fixed.

    Regards,
    Henning


    1. Swartland-Tourism-Date-Filtering
    Ninja Lead Moderator
    #538555

    I just fixed it directly on your site, here is what I have changed.


    function cmp($a, $b)
    {
    if($a->created == $b->created) {
    return 0 ;
    }
    return ($a->created > $b->created) ? -1 : 1;
    }
    $a = $this->intro_items;
    usort($a, "cmp");
    $this->intro_items = $a;

    Please check again and let me know if it helps.


    1. sort_array
    Henning Friend
    #538597

    Hi Ninja Lead,

    It’s fixed, thanks a bunch, just had a look and the filtering is working 100% according to the ‘most recent first’ and ‘created date’ parameters.

    Just another question; How do I set the filter on those articles to display the most recent date instead of the last date? It should start from January to December. It’s currently showing from December to January.

    Thanks again for your help! I appreciate it sincerely!

    Kind Regards,
    Henning

    Henning Friend
    #538711

    Hi Ninja Lead,

    Were you able to have a look at my question posted in the previous topic?

    “How do I set the filter on those articles to display the most recent date instead of the last date? It should start from January to December. It’s currently showing from December to January.”

    Regards,
    Henning

    Ninja Lead Moderator
    #538745

    Hi Henning,

    I just fixed it as your request. For now, It’s showing from January to December. Here is my workaround

    function cmp($a, $b)
    {
    if($a->created == $b->created) {
    return 0 ;
    }
    return ($a->created < $b->created) ? -1 : 1;
    }
    $a = $this->intro_items;
    usort($a, "cmp");
    $this->intro_items = $a;

    Regards

    Henning Friend
    #538755

    Hi Ninja Lead,

    Well done! It’s fixed! Thank you very much, your support was most appreciated!

    Regards,
    Henning

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

This topic contains 14 replies, has 2 voices, and was last updated by  Henning 10 years, 5 months ago.

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