Answering my own question, just in case it is useful to someone else.
If you have a series of questions in KB.Questions, with each page having one
(and one only) title, and you want to search them and have the question
titles show up, here is what your search page should look like:
--cut here--
1 Search the Knowledge Base
#set($formatDate = "MMMM dd, yyyy HH:mm")
#if ($request.getParameter("text"))
#set ($text = $request.getParameter("text") )
#else
#set($text = "")
#end
<center>
<form action="WebSearch">
<input type="text" name="text"
value="$!text"> <input type="submit"
name="search" value="Search">
</form>
</center>
#if($text!="")
1.1 Questions
#set ($sql = "where doc.web = 'KB.Questions' and doc.content like
'%$text%'
order by doc.date desc")
#set ($start = 0)
#set ($nb = 50)
#foreach ($item in $xwiki.searchDocuments($sql , $nb , $start))
#if ($xwiki.hasAccessLevel("view", $context.user,
"${context.database}:${item}"))
#set($bentrydoc = $xwiki.getDocument($item))
#set($bentrytoc = $bentrydoc.getTOC(0,2,true))
#foreach ($tocentry in $bentrytoc.keySet())
#set($toc = $bentrytoc.get($tocentry))
* [$toc.text>${bentrydoc.web}.$bentrydoc.name]
#end
#end
#end
--cut here--
The multiple foreach loops are the key here. You can do something similar
in the RSS feed.
-Adrian
On 5/8/06 1:31 PM, "Adrian Hall" <ahall(a)mirapoint.com> wrote:
According to the Javadoc, there is a TOC associated
with each document, and
it is retrieved by getTOC()
I understand it is a map of a map. Can someone shed some light onto how it
is organized?
What I am trying to do is use velocity to get the first heading in a
document. i.e. every document starts with 1 <heading> and I wish to display
this in RSS and search results.
-Adrian
--
Adrian Hall
Sr. Product Line Manager, Administration and Identity Management
e. ahall(a)mirapoint.com; t. +1 (408) 720-3856; c. +1 (408) 667-4977