Table of Contents
Compatible with DokuWiki
- 2022-07-31 "Igor" unknown
- 2020-07-29 "Hogfather" unknown
- 2018-04-22 "Greebo" yes
- 2017-02-19 "Frusterick Manners" yes
This plugin lets you limit searches to the current namespace. Configuration options let you do this for specific namespaces, for all namespaces, or for all base namespaces.
Combined with the loadskin plugin, the right edit permissions, and an empty root namespace, this plugin can make your wiki act like it's several different wikis.
Configuration and Settings
There is only one configuration setting, which is a semicolon-delimited list of namespaces. Any search done in these namespaces will be limited to results from the given namespace.
In this case, searches from within myns:sub or myns:sub:whatever will only return results from myns:sub and its sub-namespaces. Searches from within myns or myns:sub2 will return results from within myns.
Special value: @all
If you use this value, searches will be limited in all namespaces to the current namespace. Searches in myns will be limited to myns. Searches in myns:sub will be limited to myns:sub. Searches in myns:sub:sub2:sub3:sub4:sub5 will be limited to results from myns:sub:sub2:sub3:sub4:sub5. You get the idea.
Special value: @base
If you use this value, searches will be limited to base namespaces. Searches in myns or myns:sub or myns:sub:sub2:sub3 will all return results from myns.
Special value: @depth[n]
If you use this value, searches will be limited to a depth of [n]. For example, using @depth1, searches in myns:sub:sub2 will be limited to results from myns:sub. @depth0 is equivalent to @base.
There's no simple way to determine which page you came from while searching, so this plugin uses the last breadcumb to make a good guess. However, if you leave a window open for a long time (several days), the breadcrumb list vanishes. If you then do a search from that old page, the namespace limitations will be ignored, and you'll get results from everywhere.
- Added @depth feature, from an anonymous feature request.
- Fixed bug where, if you let the breadcrumb list expire, a search would give no results.
- Initial release.
Would it be easy to support an option that *excludes* certain namespaces from search results?
eg: '@all;-:private' (exclude anything from the root namespace ':private') '@all;-private' (exclude anything from a namespace named 'private' under the current namespace)
2011-11-11 m [dot] mccarn [at] aicr [dot] org
Here's what I think you're asking for: Search works in the normal DokuWiki way, but no results will come back from certain namespaces. Is that right? It shouldn't be too hard to implement that. I'll think about it.
You can already do what you want to some extent with a normal DokuWiki installation – just limit access to the :private namespace to certain groups. Other groups won't see search results from that namespace. Also, if you use this plugin as designed, you can use the “@base” setting to limit searches to the current namespace. So you could only search in :private if you were currently looking at a page in :private.
Or you might be asking for this: Limit searches to within the current namespace, but if you're in :private, you won't get any search results at all.
Have a look at these variables: - restrictionNS - restrictionType
should be standard IMO. . .
So what I think you're asking for is this: Restrict search in some namespaces, and don't restrict search in others. For example, when you're in ns1, search results only come back for ns1, but when you're in ns2, you can get results from either ns1 or ns2 (or anywhere else). I'll think about implementing that feature, but it will result in behavior that will confuse some users. Maybe this would be better (but more complicated):
- Namespaces: ns1, ns2, ns3, ns4
- Restrictions: @base, -ns3, -ns4
- Search in ns1: Results are only from ns1.
- Search in ns2: Results are only from ns2.
- Search in ns3: Results are from ns3 and ns4, but not from ns1 or ns2.
- Summary: In addition to only seeing results from the current namespace, you can't get results from a restricted namespace when you're in any other namespace.
Restrict According to Namespace Depth
Feature complete. See @depth, above. (full feature request removed to keep the page clean).
Hey Eli, I really appreciate your implementing my feature request. It works exactly as you described, but slightly different than I envisioned for our use. I was looking for a solution that returns hits from within the current [n]-level directory and deeper. If I understand correctly, your solution returns hits from within the X-level directory and deeper. The difference is the current.
Put differently, could the code start by grabbing the current directory, then limiting search results to a certain folder depth within that current directory?
Example: If I'm here
And I make a search for “ford”, I'd want to see results from these folders:
Big time thanks !
Restrict Search for Current Language
Feature request. I have two main namespaces for English and Italian languages each namespace contains sub-namespaces.
How to restrict search within /it or /en namespace? English readers should find only English articles when they start search from any English sub-namespace. I don't know a depth of search, because users can run search from any embedded namespace.
Thanks in advance!
zioth: You're describing the way this plugin works. Just set the config parameter to en;it. If you do that, any user inside of en will only search English pages, and any user inside it will only search Italian pages. This works because you've decided to put the language as the first piece of the namespace. If your structure were different (main-window:en, main-window:it), this plugin wouldn't support that.
Did I understand your question correctly?
/Igor Kokarev/ Thanks for your answer! Yes, I tried to set en;it but search always works in both namespaces - English and Italian.
You can try in my Dokuwiki: docs.picturestoexe.com/en/main
For example, I run search from docs.picturestoexe.com/en/main but I see results from docs.picturestoexe.com/it/…
P.S. I also tried selectsearch plug-in and it worked correctly.
zioth: Strange. I wonder if my plugin doesn't work right with the latest dokuwiki version. Does @base work?
Reply (Igor Kokarev)
No, @base also doesn't work.
I use the latest Dokuwiki “Binky”.
zioth: Sorry. I don't have time to upgrade to Binky right now. I will eventually, and then I can post an update to this plugin.
Reply (Igor Kokarev)
I just installed a new copy of “Binky” in a new folder. Search works correctly within current namespace with nssearch. It seems that my main dokuwiki has some conflict in options.