+ Reply to Thread
Results 1 to 3 of 3

Thread: wiki.search on page title

  1. #1
    Join Date
    Oct 2007
    Location
    Amsterdam, the Netherlands
    Posts
    105

    Question wiki.search on page title

    On many of my wiki pages I have a div block with "related info" Often I use the following:

    Code:
    {{ wiki.search{query: page.title, max: "10"} }}
    This works really nice, but it falters when I have a compound title, such as "James Brown"
    I want it to search for James Brown exactly, not just the pages with James OR Brown. So I devised the following script, but it doesn't seen to work:
    Code:
    {{ wiki.search{query: "'"..page.title.."'", max: "10"} }}
    Should I use escape characters or something? The syntax is correct, but the search still results in James OR Brown..
    Last edited by gouwzee; 08-06-2009 at 09:03 AM. Reason: typo

  2. #2
    Join Date
    Oct 2007
    Location
    Amsterdam, the Netherlands
    Posts
    105

    Cool solution

    Okay, I experimented some using escape characters and found the solution myself
    Code:
    {{ wiki.search{query: "\""..page.title.."\"", max: "10"} }}
    Works nice!

  3. #3
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    Similarly, you could also do:
    Code:
    {{ wiki.search{query: '"'..page.title..'"', max: "10"} }}
    If you run MindTouch 2009 or later, you should also use string.searchescape to escape special characters from the search.
    Code:
    {{ wiki.search{query: '"' .. string.searchescape(page.title) .. '"', max: "10"} }}
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts