Forums / Setup & design / Error when searching

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Error when searching

Author Message

Kjell Inge Sandvik

Wednesday 31 August 2005 7:55:36 am

Hello again!

I want to make a (simple) searchform, and the template for this is:

{set-block scope=root variable=cache_ttl}0{/set-block}
<div id="mediaSok">
	<div id="tittel"><h2>Mediasøk<img src={"mappeIkon.gif"|ezimage}></h2></div>
	<form action={"/content/advancedsearch/"|ezurl} method="get">
		<input class="inputText" type="text" name="AnyWordSearchText" value="" />
		<select size="1" class="inputSelect" name="SearchContentClassID">
			<option value="-1" selected>Alle medium</option>
			<option value="77">Bilder</option>
			<option value="84">Dokumenter</option>
			<option value="95">Media</option>
		</select>
		<input class="inputSubmit" name="SearchButton" type="submit" value="" />
	</form>
</form>
</div>

When executed, I get a rather ugly error:
<i>Fatal error: Call to a member function on a non-object in /home/mediabase/domains/mediabase.no/public_html/kernel/content/advancedsearch.php on line 129</i>

What is wrong here?

Sandvik Web & Data

Kristof Coomans

Wednesday 31 August 2005 11:48:39 pm

Relevant code in advancedsearch.php:

if ( $http->hasVariable( 'SearchContentClassID' ) and
     $http->variable( 'SearchContentClassID' ) != -1 )
{
    $searchContentClassID = $http->variable( 'SearchContentClassID' );
    $searchContentClass =& eZContentClass::fetch( $searchContentClassID );
    $searchContentClassAttributeArray =& $searchContentClass->fetchSearchableAttributes();
}

I think one of the option values in your template is not a valid content class ID, and eZContentClass::fetch( ) returns false. $searchContentClass is not an object, and you'll get the error.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Kjell Inge Sandvik

Thursday 01 September 2005 12:48:04 am

How can I proceed here?

Sandvik Web & Data

Kristof Coomans

Thursday 01 September 2005 12:57:13 am

Check the class ID's of Bilder, Dokumenter and Media.

You can also make the options more dynamic with the following code, if you can assume the class identifiers won't change:

{def $classes=fetch( 'class', 'list', hash( 'class_filter', array( 'bilder', 'dokumenter', 'media' ) ) )}
 
{foreach $classes as $class}
    <option value="{$class.id}">{$class.name|wash}</option>
{/foreach}

{undef $classes}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org