You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Ben Avery <be...@youthnet.org> on 2007/02/12 13:47:04 UTC

search problem, Roller 3.0

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


Re: search problem, Roller 3.0

Posted by Matt Raible <mr...@gmail.com>.
It sounds like this may be the same thing I entered a bug for last night:

http://opensource.atlassian.com/projects/roller/browse/ROL-1344

Matt

On 2/12/07, Ben Avery <be...@youthnet.org> wrote:
> 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
>
>


-- 
http://raibledesigns.com