[pmwiki-users] Parsing search query to the $opt variable

Gregor Klarič klaric.gregor at gmail.com
Wed Jun 28 09:39:54 PDT 2023


Thank you Petko, I got it working.
Ultimately, the problem was not (only) in the $opt building process, but I
had the markup executed at the wrong time in the page creation process.
I had it with 'style", but at that time in the  $query
 "'''UPORABNOST''': strupen
has already been converted to
 <strong>UPORABNOST</strong>: strupen, and thus it never found the phrase
on the pages.
I moved the markup to <inline,  and now it works correctly.

Am Mi., 28. Juni 2023 um 13:54 Uhr schrieb Petko Yotov <5ko at 5ko.fr>:

> In theory, you should be able to do something like this:
>
>    $query = "seznam×nadaljevalni \"'''UPORABNOST''': strupen\"
> name=-$pagename";
>
>    $opt = ParseArgs($query, $GLOBALS['PageListArgPattern']);
>
> This should populate the $opt array like this:
>
>    $opt = [''=>["seznam×nadaljevalni", "'''UPORABNOST''': strupen"],
> 'name'=>"-$pagename" ];
>
> Or you can define this array yourself if it makes more sense to you.
>
> The element with an empty key $opt[''] is an array with all words or
> phrases that are required to be in the page texts.
>
> Then you should be able to use this with:
>
>    $list = []; # defined before next line
>    FPLTemplatePageList($pagename, $list, $opt);
>    # use $list
>
>
> In pagelist.php, the parsing of the query string happens in the first 30
> lines of FmtPageList() but indeed it is complicated to follow, as these
> are merged with some default settings, and with any request variables.
>
> Petko
>
>
> On 28/06/2023 13:18, Gregor Klarič wrote:
> > I am using the  FPLTemplatePageList function in a custom markup in
> > this way
> >
> > $opt = [''=>$searchwords, 'name'=>"-$pagename" ];
> >  FPLTemplatePageList($pagename, $list, $opt);
> >
> > where  $searchwords is an array of the search words which I am
> > providing by parsing the parameters of my markup. I don't seem to
> > parse it right though.
> >
> > I would like to parse this search query as it is:
> > seznam×nadaljevalni "'''UPORABNOST''': strupen"
> >
> > to produce this result:
> >
> >
> https://www.gobe.si/Gobe/AgaricusAugustus?fmt=%23title&order=title&name=-*RecentChanges*&action=search&q=seznam%C3%97nadaljevalni+%22%27%27%27UPORABNOST%27%27%27%3A+strupen%22
> >
> > but I can not find the piece of code in pagelist.php that pases this
> > and builds the correct  $searchwords and  $opts variable.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20230628/1c4c6134/attachment.html>


More information about the pmwiki-users mailing list