2011/12/18

Search Portlet for Current Section

By default, Plone provides a searchbox viewlet and a search portlet. With the viewlet, you can decide whether to search only within the current section. However, the porlet does not apply this behavior. My requirement could be illustrated by this screenshot:

Here are the files to be modified:

$ diff plone/app/portlets/portlets/search.py
55a56,61
>     def folder_path(self):
>         context_state = getMultiAdapter((self.context, self.request),
>                                          name=u'plone_context_state')
>         folder = context_state.folder()
>         return '/'.join(folder.getPhysicalPath())
>

$ diff plone/app/portlets/portlets/search.pt
29a30,44
>
>         <div class="searchSection">
>             <input id="searchbox_currentfolder_only"
>                    class="noborder"
>                    type="hidden"
>                    name="path"
>                    tal:attributes="value view/folder_path"
>                    />
>             <label for="searchbox_currentfolder_only"
>                    i18n:translate="label_searchbox_currentfolder_only"
>                    style="cursor: pointer">
>                 only in current section
>             </label>
>         </div>
>

No comments: