Re: PAGE SUBSET SEARCHING

"Graham Honey" <[email protected]> Mon, 3 Dec 2007 09:25:25 +1030
Newsgroups gmane.comp.cms.jahia.devel
Message-ID <[email protected]>
Hi all,

 

I am following up on the email below.  Any assistance would be greatly
appreciated.

 

Kind Regards

 

Graham

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Graham Honey
Sent: Thursday, November 29, 2007 4:23 PM
To: [email protected]
Subject: [dev_list] PAGE SUBSET SEARCHING
Importance: High

 

Hi all,

 

I hope you can assist.  We have used and adapted the code mentioned on
page 84 of the template development guide to enable page subset
searching, however it consistently captures/searches every page within
the site.  Instead of just  pages under the current page.  The code from
the PDF had to be updated to user StringBuilder as we were getting a
number of errors.  Does anyone know why this is capturing every page
within the site and not limiting the search results to the pages under
the existing page.

 

http://www.jahia.net/jahia/webdav/site/jahia_net/shared/Documentation/5.
0.3/Jahia5TemplateDeveloperGuide.pdf

 

Many thanks in advance.

 

Graham

 

 

Code:

 

 

<div id="search">

  <form name="searchForm" method="post"
action="<%=jData.gui().html().drawSearchLauncher()%>"
onSubmit="checkMaxPageItems(document.searchForm)" >

    <p>

      <label>Search for</label>

      <input type="text" name="search"
value='<%=JahiaTools.getStrParameter(request,"search","")%>' />

 

    <input type="hidden" name="maxPageItems" value="10" />

    <% if (advSearchLicenseEnabled){ %>

 

<a
href="javascript:checkMaxPageItems(document.searchForm);setFreeSearchInp
ut(document.searchForm);document.searchForm.searchView.value='advSearch'
;document.searchForm.submit()"><content:resourceBundle
resourceBundle="jahiatemplates.Corporate_portal_templates"
resourceName="search.advancedSearch" defaultValue="Advanced search"
/></a>

    <% } %>

    <input type="hidden"
name="<%=PageSearchResultBuilderImpl.ONE_HIT_BY_PAGE_PARAMETER_NAME%>"
value="true" />

    <input type="hidden" name="searchView" value="simple" />

    <input type="hidden" name="searchHandler" value="advSearch" />

    <input type="hidden" name="freeSearch" value='' />

    <input type="hidden"
name="<%=Search_Engine.SEARCH_REFINE_ATTRIBUTE%>" value="" />

    </p>

    <p>

      <select name="type">

        <option value="0">All</option>

        <option value="1">News</option>

        <option value="2">Resource</option>

      </select>

    </p>

    <p class="action">     

      <a
href="javascript:checkMaxPageItems(document.searchForm);setFreeSearchInp
ut(document.searchForm);submitSimpleSearchForm();document.searchForm.sub
mit()"><input type="image" src="/../images/btn_go.gif" alt="Go" /></a>


    </p>

            <%

                  //get the current pageID

                  ContentPage startPage =
ContentPage.getPage(jData.page().getID());

                  //get the list of child pages to construct the query

                  //retain active and staged pages

                  int pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS |
ContentPage.STAGING_PAGE_INFOS;

                  // SiteMapViewHelper.DISPLAY_ALL_LEVEL means that all
subsequent children under the

                  // current pageID node in the tree will be returned.

                  // SiteMapViewHelper.DEFAULT_LEVEL means that only the
immediate children under the

                  // currentpageID node in the tree will be returned.

                  FlatSiteMapViewHelper flatSiteMap = new
FlatSiteMapViewHelper(jParams, jParams.getUser(),

                  startPage, pageInfosFlag,
jParams.getLocale().toString(),

                  FlatSiteMapViewHelper.DEFAULT_LEVEL);

                  //Append the pageID of selected children to the
current query string

                  StringBuilder bob = new StringBuilder();

                  bob.append("(");

                  for (int j = 0; j < flatSiteMap.size(); j++) {

                  int pageId = flatSiteMap.getPageID(j);

                  if (j > 0){

                  bob.append(" OR ");

                  }

                  bob.append("pageid:" + pageId );

                  }

                  bob.append(")");

                  searchQuery = bob.toString();

                  %>

                        <h2>Current page id: <%=
ContentPage.getPage(jData.page().getID()) %></h2>

                        <h3>search string: <%= searchQuery %></h3>

                  <%                

            %>

  </form>

</div>

 

 Please consider the environment before printing this
email<http://media.educationau.edu.au/ecosig.gif> 

 <http://media.educationau.edu.au/disclaimer.jpg> 

IMPORTANT: This e-mail, including any attachments, may contain private
or confidential information. If you think you may not be the intended
recipient, or if you have received this e-mail in error, please contact
the sender immediately and delete all copies of this e-mail. If you are
not the intended recipient, you must not reproduce any part of this
e-mail or disclose its contents to any other party. This email
represents the views of the individual sender, which do not necessarily
reflect those of education.au limited except where the sender expressly
states otherwise. It is your responsibility to scan this email and any
files transmitted with it for viruses or any other defects. education.au
limited will not be liable for any loss, damage or consequence caused
directly or indirectly by this email.

_______________________________________________
dev_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/dev_list