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

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

eZ debug

Timing: Jan 19 2025 00:26:33
Script start
Timing: Jan 19 2025 00:26:33
Module start 'layout'
Timing: Jan 19 2025 00:26:33
Module start 'content'
Timing: Jan 19 2025 00:26:33
Module end 'content'
Timing: Jan 19 2025 00:26:33
Script end

Main resources:

Total runtime0.0152 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 589.8047152.6250
Module start 'layout' 0.00460.0035 742.429739.4453
Module start 'content' 0.00810.0050 781.875093.4297
Module end 'content' 0.01310.0021 875.304734.3047
Script end 0.0152  909.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002818.2369140.0002
Check MTime0.00149.1420140.0001
Mysql Total
Database connection0.00053.349010.0005
Mysqli_queries0.002617.000830.0009
Looping result0.00000.091010.0000
Template Total0.001711.310.0017
Template load0.00095.868210.0009
Template processing0.00085.388210.0008
Override
Cache load0.00064.210210.0006
General
dbfile0.00021.565580.0000
String conversion0.00000.072240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs