Home Features Demos Download Installation User Manual Developer Manual Relation function Credits

Login

Template:CustomSearch

{{relation|

set query = "{{query}}"
set start = "{{start}}"
set limit1 = "{{limit}}"
set previous = "{{previous}}"
set next = "{{next}}"

if start == "" 
set start = 0
end if

if limit1 == ""
set limit1 = 50
end if

// search in name and paragraph
filter _namespace "main", _name, _displayname, _paragraph query
update _paragraph = resume(_paragraph,255,1)
write "paragraphs"
filter _namespace "main", _name query, _displayname, _paragraph
update _paragraph = resume(_paragraph,255,1)
union

// remove subpages
extend _nameint = replace(replace(replace(_name,"/de",""),"/fr",""),"/en","")

// rating
project _nameint, _paragraph count, _paragraph first
rename _nameint _name, _paragraph_first _paragraph
order _paragraph_count 9
project _name, _paragraph

// add counter
dup
project _name count
set nc = _name_count
set ende = min(start+limit1-1,nc)
set ncs =  start. " - " . ende . " / ". nc

if start > 1 
set ncs = ncs . previous
end if

if start + limit1 -1 < nc 
set ncs = ncs . next
end if

pop

// show results with interesting paragraph
limit start limit1

read "paragraphs"
extend row = rownumber
project inline _name, row min
select row = row_min
project _name, _paragraph 

join left

// create a query to be split
set v =  query . " "
set c = length(v)
set i = 1
set l = 0

// set query in paragraph bold
while i < c
if substr(v,i,1) == " " or substr(v,i,1) == "|"
if i > l
set s = substr(v,l,i-l)
update _paragraph = regexreplacemod(_paragraph,s,"'''".s."'''","i")
end if
set l = i + 1
end if
set i = i + 1
end while

update _name = "<br>[["._name."|"._displayname."]]<br>". _paragraph 
project _name
label _name ""

echo ncs
print grid
echo " "
}}