eZ Community » Forums » Setup & design » Error when searching
expandshrink

Error when searching

Error when searching

Wednesday 31 August 2005 4:55:36 pm - 3 replies

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?

Thursday 01 September 2005 8:48:39 am

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.

Thursday 01 September 2005 9:48:04 am

How can I proceed here?

Thursday 01 September 2005 9: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}

Modified on Thursday 01 September 2005 9:58:00 am by Kristof Coomans

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from