mprins / pagequery

An all-in-one, multi-column page listing plugin for Dokuwiki
https://www.dokuwiki.org/plugin:pagequery
5 stars 4 forks source link

display:title; still displays page name #6

Closed tomio13 closed 2 years ago

tomio13 commented 2 years ago

environment

expected behaviour

{{pagequery> ^equipment:large_scale; fullregex; display=title; }} Expected to display the first header of each pages.

actual behaviour

It displays the dokuwiki page names, independent of what I do to display.

steps to reproduce actual behaviour

Just try setting display to title.

error log

No error displayed.

suggested solution

In PageQuery.php, in function htmlwikilink, replace:

bool $display to string $disaplay in line 974, and use the original form 983 (currently commented out) instead of 947, that is: $link = html_wikilink($id, $display);

in PageQuery.php:

 private function htmlWikilink(
        string $id,
        string $display,
        // bool $display,
        string $abstract,
        array $opt,
        bool $track_snippets = true,
        bool $raw = false
    ): string {
        $id = (strpos($id, ':') === false) ? ':' . $id : $id;   // : needed for root pages (root level)
        // TODO find out if this is an API change in DW
        $link   = html_wikilink($id, $display);
      //$link   = html_wikilink($id);
...

Then it works properly (at least for using title).

mprins commented 2 years ago

please provide a proper pull request with a unit test; I'm not at home in this inherited and convoluted codebase.

this may be an API change in DW, making your suggested fix break with the current release candidate.

As you can see there is no function html_wikilink that takes a boolean as the second argument: https://xref.dokuwiki.org/reference/dokuwiki/inc/html.php.source.html#l34

tomio13 commented 2 years ago

I am sorry, you lost me here...

(It was a post 5 months ago.)

In the file PageQuery.php on line 974 the plugin defines $display as boolean. If you change that to string and call the html_wikilink() as html_wikilink($id, $display) (as the commented out line in line 982), the code is fixed.

Using $display as text, it gets sent as a $title to $xhtml_renderer->internallink($id,$name,$search,true,'navigation');

mprins commented 2 years ago

I've created https://github.com/mprins/pagequery/pull/11 with your suggested fix

tomio13 commented 2 years ago

Thank you!