Query Function

50 views
Skip to first unread message

Bruno Diazzi

unread,
Sep 30, 2019, 4:34:33 AM9/30/19
to BoltWire
Hallo,
I need to select pages with a certain tag.
I have tried with action.tag: no pages found.
I have tried with [(query page=index.tags text=whatever fmt='[[{+p}]]')]: no page founds.
I have tried with [(query page=index.tags #1(+)whatever fmt='[[{+p}]]')]: and this works properly, but it isn't what I need, because whatever shoud not be part of a word.
I need your help.
Thanh you.

Dan Vis

unread,
Sep 30, 2019, 1:00:59 PM9/30/19
to BoltWire
Wow, that took me a good while to figure out. I don't use tags myself, and it turns out there is a glitch in the software added from a recent update that I hadn't noticed and no one had reported. :(

Fortunately there's an easy fix:

Go to engine.php and comment out line 357 so it looks like this:

// if ($args['text'] != '') $value = BOLTMtexttools(array('', $args['text'], $value));

At some point I added a way to integrate text formatting features directly into the function output, but the text= parameter is also part of the tagging system, so you have the conflict right there.

A better way to fix it would be to change the format of the tag command from 

[(query page=index.tags text=whatever fmt='[[{+p}]]')]   to   [(query page=index.tags tag=whatever fmt='[[{+p}]]')] 

But that would be a bit more complicated, so I'll put that on my to do list to figure out how to do this optimally. And hopefully without breaking sites.

Actually, thinking out loud, if you want to retain the text formatting capabilities, you could for now replace line 357 with these four lines:

if ($args['text'] != '') {
     $value2 = BOLTMtexttools(array('', $args['text'], $value));
     if ($value2 != '') return $value2;
     }

That actually seems to fully solve the conflict. And using a tag= parameter may not be the best approach anyway as text= is used for regular text based searches that don't involve tagging.

Anyway, let me know if this doesn't solve the problem for you. I probably won't do a release for this small fix as I'm working on a bigger release for the near future, but will be sure to include some fix when I do. And it won't hurt to think about this a bit more to make sure we get it fixed right...

Thanks for reporting this! I was actually thinking about adding tag capabilities to my own site sometime soon. Should be easier now that it is working!

Cheers,
Dan


--
You received this message because you are subscribed to the Google Groups "BoltWire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boltwire+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/boltwire/49db910b-36cc-40d5-9f8d-ae802cb0a017%40googlegroups.com.


--

Join me January 1 for REVIVE :: 2017
http://www.fastmissions.com/boost/fast4god

Bruno Diazzi

unread,
Oct 2, 2019, 4:39:51 AM10/2/19
to BoltWire
Thank you, Dan.
It seems to work well.
However I had to make the change not to line 356 in vers. 6.02 or line 344 in vers. 6.01 but on line 315 (v. 6.02) or line 309 (v. 6.01).
Change to line 356 or 344 dosn't work.
There are still some problems with search:
text=elephants, text=pink elephants, text=pink||elephants work properly
text=!elephants, text=pink&&elephants dosn't work.
Cheers
Bruno
To unsubscribe from this group and stop receiving emails from it, send an email to bolt...@googlegroups.com.

Dan Vis

unread,
Oct 2, 2019, 9:11:14 AM10/2/19
to BoltWire
Thanks for checking into this. I don't really use this much so it really helps to have someone assist with the debugging. 

Looks like there was a small typo in the library.php file. Probably introduced when I went to better word matching patterns and away from simple string matching. You can see a few commented out lines in yours. 

Anyway, pretty easy to fix. I actually edited a few other little things in this function to strengthen it but the main problem was a $t instead of a $tf variable in the next to last line of code. Oops. 

The best thing to do is open up library.php and replace the function below with the following code. On my version its line 1630 but yours might be different as this is off my version which has several updates built in. I'll try and go ahead and release another upgrade sometime soon that incorporates these fixes. :)

Cheers,
Dan


function BOLTqueryText3($find, $args) {
## THIS ONE TAKES CARE OF ! AND DOES ACTUAL CHECK
     global $tempSearchArray;
      if ($args['case'] != 'true') $find = strtolower($find);
      if ($args['words'] !== 'false') $s= " ";
      else $s = "<>";
      $tf = true;
      if (substr($find, 0, 1) == "!") {
            $tf = false;
            $find = trim(substr($find, 1));
            }
      if (substr($find, -1) == '*') $find = substr($find, 0, -1);
      foreach($tempSearchArray as $page => $p) {
            $line = explode(':', $p);
            $check = $s . $line[0] . $s;
            if ($args['case'] != 'true') $check = strtolower($check);
            if ($tf === true && preg_match("/\b($find)\b/ie", $check) != 0) $search[] = $page;
            elseif($tf === false && preg_match("/\b($find)\b/ie", $check) == 0) $search[] = $page;
            }
      return $search;
      }


To unsubscribe from this group and stop receiving emails from it, send an email to boltwire+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/boltwire/abf12cf1-73a2-4ca5-9bde-1e4ed415d93b%40googlegroups.com.

mz

unread,
Apr 24, 2020, 10:32:50 AM4/24/20
to BoltWire
Hi Dan
I hope you are well.
It seems that this bug is still in the download file.
Even after doing the fixes, query text= does not work for me.

Greetings, Martin

mz

unread,
Apr 24, 2020, 11:51:39 AM4/24/20
to BoltWire
index.site has this line: test: pink elephant

I tried:
query page=index.site text="pink elephant" fmt ...
query page=index.site #1(,)pink -> that works

Maybe this is the cause that action.search does not work either.

Dan Vis

unread,
Apr 24, 2020, 12:43:18 PM4/24/20
to BoltWire
Hi Martin...

All is well here! Very busy with my main site growing rapidly right now.  Still I'll be glad to getting back to getting out and doing things again! :)

This is the results I get with my system:

line: pink elephant
1. [(query page={p} text="pink")] Yes
2. [(query page={p} #1(,)pink)] No
3. [(query page={p} #1(+)pink)] Yes

The (,) fails because it only works on comma separate values, the + does a simple string search. The text option seems to work for me, but I have this line updated in my script as discussed farther down in this thread:

  function BOLTqueryText3($find, $args) {
## THIS ONE TAKES CARE OF ! AND DOES ACTUAL CHECK
     global $tempSearchArray;
      if ($args['case'] != 'true') $find = strtolower($find);
      if ($args['words'] !== 'false') $s= " ";
      else $s = "<>";
      $tf = true;
      if (substr($find, 0, 1) == "!") {
            $tf = false;
            $find = trim(substr($find, 1));
            }
      if (substr($find, -1) == '*') $find = substr($find, 0, -1);
      foreach($tempSearchArray as $page => $p) {
            $line = explode(':', $p);
            $check = $s . $line[0] . $s;
            if ($args['case'] != 'true') $check = strtolower($check);
            if ($tf === true && preg_match("/\b($find)\b/ie", $check) != 0) $search[] = $page;
            elseif($tf === false && preg_match("/\b($find)\b/ie", $check) == 0) $search[] = $page;
            }
      return $search;
       }

I haven't done a release since doing that fix, so the current download has not yet been corrected.

I'm actually working on a pretty big release but I'm right in the middle of several new features and it's awkward to do a release midstream like this. I'm learning more towards a 7.x version at this point as it has been over a year. 

Can you check to see if you have the function above in library.php updated? I could download and upload 6.02 with that one fix, but with so many other fixes in my script, I think it's better to wait and just do a big release in the near future.

Let me know...

Cheers,
Dan

PS. I'm inclined to get rid of the text= link= options as they are specialized rules whereas the query operators are far more powerful and flexible. I did check the search action as well, and it worked for me. But you do have to have the correct index populated with data. I store my indexes in special content files rather than the default index pages, so I had to adjust the search function to query the correct page...


mz

unread,
Apr 24, 2020, 5:36:06 PM4/24/20
to BoltWire
Wow, this was quick! Thank you. Happy to hear that you are well and thriving in these times.
After dinner I found a solution:

info.1: A pink elephant was waiting around the corner. Staring with blue eyes.
info.2: A pink elephant lives in a box.

#1(1)'/pink.*elephant.*blue/' 

Easy. I can work with that.

Like you I store all content on one info page and perform searches on this page.
I wanted to have a search with more than one keyword on info parts that contain more text.

In fact I am working to provide some examples. Alexdp asked for these a couple of days ago. He is right. BoltWire is perfect to whip up a website, provide community information, teach pupils, organize yourself etc. We all have to stay at home (not in ND, its empty, but in Europe) and we have to learn to work with the internet.

Of course I look forward for v7. Meanwhile, maybe you can update these two files only for the download.

Greetings, Martin
Reply all
Reply to author
Forward
0 new messages