How to return search results for local node in siteaccess?

Author Message

Tony Coe

Friday 18 August 2006 3:20:07 am

Apologies if this has been answered elsewhere. I did look, but couldn't find anything.

Basically I am setting up EZP to run accross several different domains, with each domain using a different siteaccess. I am having trouble making the search function for each domain only return results for the relevant node.

I created an override template for searchbox.tpl for the relevant siteaccess and changed the node ID in the code as per below:

<form action={"/content/search/"|ezurl} method="get"><input class="searchinput" type="text" size="10" name="SearchText" value="" />
<input type="image" class="searchimage" src={"1x1.gif"|ezimage} />
{section show=$relative_check|eq( 'yes' )}
{section show=is_set( $module_result.content_info.node_id )}
    {let node_id=$module_result.content_info.node_id}
    {section show=$node_id|ne( 150 )}
    <div class="optionblock">
        <input type="radio" class="radiobutton" name="SubTreeArray[]" value="" /><label for="search-global">{'Global'|i18n( 'design/standard/toolbar/search' )}</label>
        <input type="radio" class="radiobutton" name="SubTreeArray[]" value="{$node_id}" checked="checked" /><label for="search-here">{'From here'|i18n( 'design/standard/toolbar/search' )}</label>
    </div>
    {/section}
    {/let}
{/section}
{/section}
</form>

I assumed that it would simply be a case of changing the line
{section show=$node_id|ne( 2 )}
to
{section show=$node_id|ne( 150 )}

As I just want it to return results from node 150 (and sub-nodes thereof). However, it doesn't seem to have any effect, so this obviously isn't the case.
Please can someone advise how I achieve a local search per siteaccess?

Sorry if this is a really dumb question - I'm still finding my way around EZP.

Thanks!

Claudia Kosny

Sunday 20 August 2006 1:25:39 am

Hi Tony,

The line you changed just determines whether to display the options for global or local search at all but it does not change what the is posted to the search script.

I think that you have to make sure that the value for the radiobuttons is set to 150. This way the search script knows that you just want to search below the node with the id 150.

Claudia

Tony Coe

Monday 21 August 2006 3:57:05 am

Hi Claudia!

Thanks for coming back to me!

I already tried changing the line
<input type="radio" class="radiobutton" name="SubTreeArray[]" value="{$node_id}" checked="checked" />

to

<input type="radio" class="radiobutton" name="SubTreeArray[]" value="150" checked="checked" />

Again, no change.

Was that what you meant?
Thanks!

Claudia Kosny

Tuesday 22 August 2006 10:37:54 am

Hi Tony,

I suspect that the line with the radiobutton does not appear in the html produced by the template and thus is not posted to the search function.

You need no make sure that the variable SubTreeArray[] is posted with the value you want. So if you want to give your user the option to specify the subtree they want to search your form would need to look something like this:

 <form action={"/content/search/"|ezurl} method="get">
  <label for="node150">node 150</label>  
  <input type="radio" id="node150" class="radiobutton" name="SubTreeArray[]"      value="{$node_id}" checked="checked" />
  <label for="node250">node 250</label>  
  <input type="radio" id="node250" class="radiobutton" name="SubTreeArray[]"      value="{$node_id}" />
  <input type="submit" value="submit" />
 </form>

If you want to search only one subtree there is no need for any readio buttons or selectboxes. So we can submit the desired node in a hidden formfield:

 <form action={"/content/search/"|ezurl} method="get">
 <input type="hidden" name="SubTreeArray" value="150" />
  <input type="submit" value="submit" />
 </form>

If it still does not work, please post the entire search form (beginning and ending with the form tag) here.

Greetings from Luxembourg

Claudia

Tony Coe

Thursday 24 August 2006 7:12:47 am

Hi Claudia!

Thank you for helping me!

I used a simplified form, along the line you suggested:

 <form action={"/content/search/"|ezurl} method="get">
<input class="searchinput" type="text" size="10" name="SearchText" value="" />
 <input type="hidden" name="SubTreeArray" value="150" />
 <input type="submit" value="submit" />
 </form>

But now it only returned the front page as a result.
I had a bit of a play with the content (I'm not the content creator, I'm just setting up the CMS) and determined that this was because the content had all been created elsewhere in the node tree but then published at this location as well. I went in and set the 'main' location for a couple of the articles to the sub-nodes of 150 and sure enough, the search returned them in the results. However, the way that my friend wants to use the CMS is to create articles at one point and then publish them at multiple locations, so they will appear at different points on different sites (if that makes sense).

So (hopefully) one last question - Is it possible to get the search to return results from articles in the subtree even if that isn't the 'main' location of those articles?

Thanks again for all your help. If you're ever in England I definitely owe you a few drinks!

Claudia Kosny

Thursday 24 August 2006 1:14:04 pm

Hello Tony

Thanks for the offer - I might take you up on it!

As for your question with the main_node, unfortunately there does not seem to be an solution yet. Check this thread:
http://ez.no/community/forum/setup_design/searching_subtrees_only_works_for_main_locations

Greetings from Luxembourg

Claudia

Paul Borgermans

Thursday 24 August 2006 2:56:28 pm

Hi

Next week, I'll release a version of the Lucene based plugin which solves this issue. If you can install a servlet engine and the PHP-Java bridge you may consider using our plugin instead.

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Tony Coe

Monday 28 August 2006 1:23:23 am

Claudia - Thanks for all your help, you've been brilliant. I've temporarialy changed the 'main' node for all the content so at least have the search working correctly for this site.

Paul, I'll have a look at what's involved with installing the servlet engine and PHP-Java bridge and keep an eye out for when you release the Lucene Plugin. Thanks for the 'heads-up'.

Tony.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.