{% with m.search.paged[{fulltext cat=q.qcat text=q.qs page=q.page}] as result %}
<ul>
{% pager result=result dispatch="admin_overview_rsc" qargs %}
{% for id in result %}
<li><a href="">{{ m.rsc[id].title }}</a></li>
{% empty %}
<li>Nothing found</li>
{% endfor %}
</ul>
{% endwith %}
and put it in a srch.tpl and created a dispatch:
{srch,["srch"], resource_template, [ {template, "srch.tpl"}]}
but when I visit zt:8000/srch I get an error. If you want I can post
the error somewhere if it is not obvious why.
thanks,
-wes
The {fulltex ...} search doesn't just return an id but also a score. The score defines how well the page matches the search term:
> (zoton...@lamma.local)43> z_search:search({fulltext, [{text, "admin"}]}, z:c(maxclass)).
> {search_result,[{1,0.7222222089767456},
> {18601,0.23076923191547394},
> {19105,0.23076923191547394},
> {19113,0.23076923191547394},
> {18697,0.09090909361839294},
> {4134,0.09090909361839294},
> {19109,0.09090909361839294},
> {19332,0.09090909361839294}],
> 1,undefined,undefined,undefined,undefined,undefined,
> undefined}
So the loop should be:
> {% for id, score in result %}
I have corrected this on the page http://zotonic.com/scomp-pager
Best, Marc
- Marc
Would it be difficult to allow only a subset of the tuple to match?
Say if we don't care for the score, it could be left out. Not a big
issue up front, but say that m.search would like to expand the tuple
and also return a popularity ranking value, {id, score, popularity}
As it is, either all templates needs update to accommodate the new
tuple member, or, the implementation needs to be done so that the new
format is only used when explicitly requested.
The latter may be the best option, but overtime it could cause the api
to become quite cumbersome.
//Andreas
Ps.
This is the reason that I wrote: "One way would be to have the filter
return a tuple with all data parsed out, but that is a bit too rigid,
and doesn't welcome future changes."
--http://blog.astekk.se/article/347/writing-your-own-zotonic-module-part-iv
2011/6/7 Marc Worrell <mwor...@me.com>:
No, it is (django) template syntax, so it is as Marc wrote:
id, score in list
What the "don't care" syntax should look like is yet to be decided, if
it is going to be implemented.
//Andreas
2011/6/7 douglas <dvdo...@gmail.com>: