I'm having a problem with the search form working with categories. maybe I'm looking in the wrong place, but it seems the Velocimacros don't work. in WEB-INF/velocity/weblog.vm, the macro showWeblogSearchForm (and the searchagainform) has this method code:

(Roller 3.0, Tomcat 5.5.12, JRE 1.5.0)


#**
Show search form for a weblog.
*#
#macro(showWeblogSearchForm $weblog $showCatChooser)
    <form id="searchForm" method="get" action="$url.search"
style="margin: 0; padding: 0" onsubmit="return validateSearch(this)">
        <p>
          <input type="text" id="q" name="q" size="10"
              maxlength="255" value="#if($model.term)$model.term#end" />
          #if( $showCatChooser )
            #set( $cats = $model.weblog.getWeblogCategories("nil") )
            <select name="cat">
            <option value="">- In Category -</option>
            #foreach( $cat in $cats )
<option #if($cat.name == $model.term)selected="selected"#end>$cat.name</option>
            #end
            </select>
          #end
<input type="submit" value="$text.get( "macro.weblog.searchbutton" )" />
        </p>
    </form>
    <script type="text/javascript">
        function validateSearch(form) {
            if (form.q.value == "") {
                alert("$text.get("macro.weblog.searchalert")");
                form.q.focus();
                return false;
            }
            return true;
        }
    </script>
#end


now when this renders the list of categories, it tries to find the selected one by matching each category name against $model.term. but $model.term is the search term itself, not the category. and if you search for a category name, that is picked up and selected.

is this a bug, or am I looking in the wrong place?

I can't find any reference to this $model.term in the template documentation, or how to access the category chosen.

cheers


Ben Avery

Reply via email to