YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar rikard.jespersen asked

I can't get the "Publish first" option to work in widgetkit

Hi
I asked about being able to use the publish date to sort content through widgetkit here: http://yootheme.com/support/question/103730

I have now updated to the 2.9.0 version of Widgetkit and there is an option to use "publish first" and "publish last" but I can't get it to work. First of all the order is the same when I use "first" and "last" and that is of course not a good sign. Further more, none of them actually sorts the content on publish date. To be honest I can't figure out what it is sorting on. It doesn't seem to be modified or create date and those are the only other date alternatives I know about.

Best regards,
Rikard

  • Joomla
  • Widgetkit
  • Chester

3 Answers

0

Avatar roland.verhaar answered

Same happening to me,
I find in the code at
/administrator/components/com_widgetkit/src/Framework/plugins/joomla/src/ArticleHelper.php
the following:

class ArticleHelper  
{  
    public function get($params)  
    {  
        // Ordering  
        $direction = null;  
        switch ($params['order']) {  
            case 'featured':  
                $ordering = 'fp.ordering';  
                break;  
            case 'random':  
                $ordering = 'RAND()';  
                break;  
            case 'date':  
                $ordering = 'created';  
                break;  
            case 'rdate':  
                $ordering = 'created';  
                $direction = 'DESC';  
                break;  
            case 'modified':  
                $ordering = 'modified';  
                break;  
            case 'rmodified':  
                $ordering = 'modified';  
                $direction = 'DESC';  
                break;  
            case 'alpha':  
                $ordering = 'title';  
                break;  
            case 'ralpha':  
                $ordering = 'title';  
                $direction = 'DESC';  
                break;  
            case 'hits':  
                $ordering = 'hits';  
                break;  
            case 'rhits':  
                $ordering = 'hits';  
                $direction = 'DESC';  
                break;  
            case 'ordering':  
            default:  
                $ordering = 'a.ordering';  
                break;  
        }  

....

There is no case for published in this list.
The code in
/administrator/components/com_widgetkit/plugins/content/joomla/views/edit.php
shows clearly that there should be an option for published:
....

<select id="wk-order" class="uk-form-width-large" ng-model="content.data['order_by']">  
    <option value="ordering">{{'Default' | trans}}</option>  
    <option ng-if="content.data.featured" value="featured">{{'Featured Articles Order' | trans}}</option>  
    <option value="rdate">{{'Latest First' | trans}}</option>  
    <option value="date">{{'Latest Last' | trans}}</option>  
    <option value="rpublished">{{'Published First' | trans}}</option>  
    <option value="published">{{'Published Last' | trans}}</option>  
    <option value="rmodified">{{'Modified First' | trans}}</option>  
    <option value="modified">{{'Modified Last' | trans}}</option>  
    <option value="alpha">{{'Alphabetical' | trans}}</option>  
    <option value="ralpha">{{'Alphabetical Reversed' | trans}}</option>  
    <option value="hits">{{'Most Hits' | trans}}</option>  
    <option value="rhits">{{'Least Hits' | trans}}</option>  
    <option value="random">{{'Random' | trans}}</option>  
</select>

...

So, it seems that the ordering is not working when the ordering is set to published or rpublished.

Can someone please confirm?

Edited

0

Avatar roland.verhaar answered

I have added the following to:
/administrator/components/com_widgetkit/src/Framework/plugins/joomla/src/ArticleHelper.php

            case 'published';  
                $ordering = 'publish_up';  
                break;  
            case 'rpublished';  
                $ordering = 'publish_up';  
                $direction = 'DESC';  
                break;  

This will sort the articles correctly when choosing Published First or Published Last.

Know someone who can answer? Share a link to this question via email or twitter.