Search-Talk

This is a talk page for improving Search.


I want to be able to search for pages that have the character '#' at
the beginning of a line. How can I do this in PmWiki?
--gnuzoo

Try Cookbook.TextExtract

simon

That is 10 pages of instructions on my 70 inch monitor for that recipe
to do 1 search. This is for someone to use my recipe HashComments.
I think it is impractical to ask anyone to install this recipe first
so they can do a search. That looks extremely complex. My biggest problem
with PmWiki is that everything you want to do is a recipe and complex.

I want a simpler solution inside PmWiki. How difficult would it be to add a checkbox to
search specifying "Start of Line"? Or help me create a simple recipe to do this?
--gnuzoo


Can PmWiki add a checkbox to the search page Site/Search so it can be case sensitive?

My browser has that for searching on a displayed page. --gnuzoo

No, the page index and the searches are case-insensitive for ASCII text. Petko


pmwiki.org lists first the pages with matching page names ("Page names:") - how can I do this on my installation? OliverBetz February 07, 2021, at 04:21 PM

See https://www.pmwiki.org/pipermail/pmwiki-devel/2021-July/002423.html. --Petko July 25, 2021, at 08:54 AM


Would it be possible to restrict the search results to show only pages which the user has read access to ? I have been successful in implementing the id and password restrictions to pages however looks like an unauthorized user can still open the page when directed from the search result-Kannan

Yes, see $EnablePageListProtect. --Petko January 15, 2020, at 04:10 PM

Thank you it worked!!!


The documentation says "Whether you use the search box below, or the regular search box that appears at the top of this page, any search that you run from this page will provide the customized results."

I want searches entered in the top search box to produce the normal results, while searches entered in the custom search box to produce the customized results. But how? - RandyB November 13, 2013, at 08:59 AM

The customized results at Search are not done via (:searchbox :) directives, but by markup that handles the ?action=search directive.

Both searchboxes are "vanilla" searchboxes -- the customization comes in the page-markup.

To build a searchbox that provides custom twiddling, see the (:searchbox:) section at PageLists

MichaelPaulukonis November 13, 2013, at 02:47 PM

Thanks. This helped. I was looking for an unusual amount of control over the page body's searchbox results, with page formatting beyond the formatting of results dependent on whether the user entered the query into the normal searchbox in the page's header, or into the special searchbox in the page's body. In case this helps others: The solution I'm using for now is to specify in the special searchbox a parameter such as count=9999, which is unlikely to be entered by the user into the page header's search box query. Then before reaching the searchresults on the page I check the value of the count query in the URL, using the Request recipe. If it's the default value that I specified in the page body's searchbox, I know the user probably entered the query in the special search box, and can process the page accordingly. RandyB November 13, 2013, at 10:47 PM

Randy - it might be useful for others if you write that up as a recipe. MichaelPaulukonis November 14, 2013, at 03:40 PM

Done. See Cookbook:SearchboxRecognition - RandyB November 14, 2013, at 10:01 PM


Is there any way to search for A or B or C?

simon July 02, 2012, at 04:07 AM

No. --Petko October 06, 2012, at 07:24 PM


How can the searchbox be embedded in a line of text?

this should be on one line
[[{*$Group}/Recent changes]] - [[Site/Search | $[Search]]]: (:searchbox target=PmWiki/Search-Talk size=16 wrap=none:)
Recent changes - Search:
[[{*$Group}/Recent changes]] - [[Site/Search | $[Search]]]: (:searchbox target=PmWiki/Search-Talk size=16 wrap=inline:)
Recent changes - Search:
simon October 06, 2012, at 04:59 PM

Normally, a HTML <form> is a block level element like a <div> so it is usually on a new line. You may be able to use some CSS like display:inline or float:left to let it be on the same line.

this should be on one line
>>float:left<<
before &nbsp;
>>float:left<<
(:searchbox size=16:)
>><<
&nbsp; after

before  

  after

You could add some CSS rules to your local.css file. --Petko October 06, 2012, at 07:24 PM

This was an attempt to place the code from pmwiki.tmpl into a wiki page.[1]

(:input form action='{$ScriptUrl}/PmWiki/Search-Talk':)
[[{*$Group}/Recent changes]] - 
(:input hidden name='n' value='PmWiki/Search-Talk' :)
(:input hidden name='action' value='search' :)
[[PmWiki/Search-Talk | $[Search]]]: 
(:input text name='q' value='' class='inputbox searchbox smaller' :)
(:input submit class='inputbutton searchbutton' value='$[Search]' :)
(:input end:)

Recent changes - Search:

and then it occurred to me it would make more sense to use the searchbox directive.


How to suppress 'Results from' message
(:searchresults req=1 request=1:)

Is it possible to make searches accent insensitive?, eg "Te Tāhuhu" and "te tahuhu" return the same search result?

simon November 26, 2013, at 03:15 PM

You can define your own $StrFoldFunction, something like this:

  $StrFoldFunction = 'MyFoldFunc';
  function MyFoldFunc($str) {
    $str = utf8fold($str);   # if using UTF-8
    $str = strtolower($str); # if not using UTF-8

    $letters = array('ā'=>'a', 'é'=>'e', ); # etc., all letters
    # note: save the file with the encoding of the wiki (utf-8 or cp1252)

    return str_replace(array_keys($letters),array_values($letters),$str);
  }

Then delete the file wiki.d/.pageindex. That should do it.

Note that for this to work, these characters need to be stored as characters in your wiki source text, not as HTML entities like T&#257;huhu. And they will be stored as entities if your wiki is in an encoding that doesn't contain them, like Windows-1252. The encoding UTF-8 supports all characters. --Petko November 26, 2013, at 03:53 PM


PmWiki online search-results

How can I replicate on my website the behavior of the online pmwiki search-results, i.e. take advantage of the page-break every 100 lines?
Is it a particular page list template?,... or is it already incorporated and I have done something wrong that is preventing the correct operation? -- Frank Feb 25, 2018, at 8:50 PM

See https://www.pmwiki.org/pipermail/pmwiki-devel/2021-July/002423.html. --Petko


Shouldn't (:searchbox:) take "id=search" & label or aria-label directives or otherwise allow for accessibility features? Am I missing something? see https://www.w3.org/WAI/tutorials/forms/labels/ XES November 16, 2019, at 01:45 PM

The markup already produces a semantic "search" input field (not "text"[*]) with a semantic "submit" button with the label "Search". ([*] This is in the default HTML5 pmwiki-responsive skin, if yours doesn't, set $SearchBoxInputType.) We can add the aria-* attributes, but the (:searchform:) directive needs to stay backwards compatible, maintainable and documentable -- label= is already assigned; should an id= or an aria-* attributes in the directive refer to the "form", the "search field" or the "button"? So if you have to build a more complex search form with aria-* attributes, just use Forms. I'll add the aria-* and role form attributes for 2.2.121, or you could add them now by redefining $InputAttrs in config.php. --Petko November 16, 2019, at 04:23 PM


Hi, I have a bit of an odd request and I'm not sure that this is the best place to ask it, but I'm not sure of a better one. My site has lists of links, as it is an archive for works hosted on other sites. I would like to be able to tag each entry to enable easier sorting and filtering on each page itself. Ideally, I was hoping for something similar to the Tumblr tagging system, where you can select a tag and it only displays those tags, but reasonably, I think the best way to accomplish this would be to add a line of tags at the end of each entry (e.g. #tag1 #tag2) and set up a search feature that users can search for those tags.
Problem is, currently this yields results of just the page itself, and I suspect that if I were able to restrict it to just the text body of the page, it would yield a list of "#tag2 #tag2 #tag2 #tag2 #tag2" or similar. Is there a way that I might be able to set up the search so its results show, for example, something like below?

  • Title with link
    Description
    #tag1
  • Title2 with link
    Description
    #tag1
  • Title3 with link
    Description
    #tag2
  • Title4 with link
    Description
    #tag2
  • Title5 with link
    Description
    #tag1

Thanks in advance! Jimbo

To modify the default search results display on the wiki, you can modify the PageList template "#default" (copy it in Site.LocalTemplates and adapt it). The template can pull variables like {=$Title}, {=$Description}, and text variables like {=$:Tags} if you have a Tags: #tag1 #tag5 line in your pages.

Instead of "tags", PmWiki has Categories which allow flexible combinations and backlinks. So if you have in your page a text variable Categories: [[!Tag 1]] [[!Tag 3]], and in the template {=$:Categories}, people can click on the links to show all pages in these categories. See for example Cookbook:Images where we use this (in a table). --Petko

For in-page filtering there is Filterable, it can do tables and lists, see how I modified your list to add a filter box at the top. If your list is a table, we have $EnableSortable to enable clicking on column headers to order the rows. If the links are on the wiki (and not external links) you can even automate the list or table with PageLists with a custom PageList template. --Petko

The filterable cookbook is nearly exactly what I need, thank you! My current only hang-up is that one of the longest pages is sorted by alphabetized headers, which necessitates the use of a filterable field under each. I will continue to tinker with it and see how it turns out. Petko, you are a god amongst men, thank you. Jimbo

This is a talk page for improving PmWiki.Search.