[
http://jira.magnolia-cms.com/browse/MAGNOLIA-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jan Haderka resolved MAGNOLIA-2293.
-----------------------------------
Resolution: Fixed
> startLevel of simpleSearch is ignored
> -------------------------------------
>
> Key: MAGNOLIA-2293
> URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-2293
> Project: Magnolia
> Issue Type: Bug
> Components: taglibs
> Affects Versions: 3.6, 3.6.1, 3.6.3, 4.0.1, 4.2.1
> Environment: Windows Vista Business SP1
> jdk1.6.0_07
> apache-tomcat-5.5.26
> magnolia-bundled-webapp-3.6.1
> Reporter: Oliver Knorr
> Assignee: Jan Haderka
> Priority: Minor
> Fix For: 4.1.2, 4.2.x
>
> Attachments: SimpleSearchTagPatch.diff
>
>
> The startLevel attribute of cmsu:simplesearch should limit the search only to
> the current website tree, but is ignored at least in Magnolia 3.6 and 3.6.1.
> Steps to reproduce:
> # Open the demo search page
> http://localhost:8080/magnoliaAuthor/help/search.html and search for "mail".
> 5 results from inside and outside the help tree should appear.
> # In webapps\magnoliaAuthor\templates\samples\templates\sample-search.jsp,
> replace the line
> <cmsu:simpleSearch query="${param.query}" var="results" />
> with the line
> <cmsu:simpleSearch query="${param.query}" var="results"
> startLevel="1" />
> # Try the search again. Expected result: one hit
> (/magnoliaAuthor/help/user-mailing-list.html),
> actual result: all the 5 results from the first test are shown.
> The reason seems to be info\magnolia\cms\taglibs\util\SimpleSearchTag.java:
> the startLevel is respected only in the obsolete generateXPathQuery() method,
> but not in the new generateSimpleQuery().
> I could fix the problem for me, by replacing
> {code}
> protected String generateSimpleQuery(String input) {
> // jcr and xpath escaping :
> final String escapedQuery = input.replace("'", "\\''");
> return "//*...@jcr:primaryType='mgnl:content']//*[jcr:contains(., '"+
> escapedQuery +"')]";
> }
> {code}
> with the following (taking the code from generateXPathQuery()):
> {code}
> protected String generateSimpleQuery(String input) {
> // search only in a specific subtree
> startPath = "";
> if (this.startLevel != 0) {
> try {
> Content activePage = Resource.getActivePage();
> if (activePage != null) {
> startPath =
> StringUtils.strip(activePage.getAncestor(this.startLevel).getHandle(), "/");
> //$NON-NLS-1$
> }
> }
> catch (RepositoryException e) {
> log.error(e.getMessage(), e);
> }
> }
> // jcr and xpath escaping :
> final String escapedQuery = input.replace("'", "\\''");
> return
> startPath+"//*...@jcr:primaryType='mgnl:content']//*[jcr:contains(., '"+
> escapedQuery +"')]";
> }
> {code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------