Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortkey configuration doesn't work; entries are always sorted by creation date #119

Open
wataradio opened this issue May 9, 2023 · 5 comments

Comments

@wataradio
Copy link

sortkey configuration doesn't work; entries are always sorted by creation date.

sortkey available options:

  • creation date
  • modification date
  • page name
  • page ID
  • page tiltle

versions

Blog Plugin 2023-01-12
dokuwiki 2023-04-04 "Jack Jackrum"
PHP 8.1.2-1ubuntu2.11

@wataradio
Copy link
Author

wataradio commented May 9, 2023

I checked blog plugin's helper.php and noticed helper_plugin_blog class's constructor is not called, so $this->sort valiable is empty.

helper.cpp

class helper_plugin_blog extends DokuWiki_Plugin {
    var $sort       = '';      // sort key
    function helper_plugin_blog() {
        // load sort key from settings
        $this->sort = $this->getConf('sortkey');
    }

By chagning the constructor as follows, sort valiable is set and entries are sorted expectedly with sortkey configuration.

class helper_plugin_blog extends DokuWiki_Plugin {
    var $sort       = '';      // sort key
    function __construct() {
        // load sort key from settings
        $this->sort = $this->getConf('sortkey');
    }

@fiwswe
Copy link
Contributor

fiwswe commented May 9, 2023

This is caused by a change in PHP 8.0.0. See: Other incompatible Changes

But to stay backward compatible for users still running PHP <8.0.0 and to avoid code duplication maybe just implement __construct like this:

function __construct() {
        $this->helper_plugin_blog();
    }
    …

@chrisisbd
Copy link

I'm still seeing this problem, I have the latest version of the blog plugin installed and it has the changed code as noted above.

I'm running on Debian 12 which has PHP version 8.2.

But if I have {{blog>blog?10&sortkey=pagename}} the blog files are sorted by creation date. No sort key seems to change anything.

@chrisisbd
Copy link

Further to the above, setting the sort key in Dokuwiki's "Configuration Settings" does work, but I can't seem to change the sort key using the blog syntax (as above) in a Dokuwiki page. Do I have the syntax right?

@chrisisbd
Copy link

Ah! I think the light has dawned (on me that is). The sortkey option can only be set in the "Configuration Settings", it's not available in the page syntax. That's a pity really, maybe I should ask for an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants