Search, advancedsearch and custom SQL scripts

Author Message

Aleksander Lech

Friday 09 September 2005 6:18:42 am

Hi,
I'm trying to achieve something like this:
Searching works as ususal but <form action> on the search page points to my extension where (based on searched term) another search is made on custom DB tables. Both search results are presented on results page.
And its work to this moment.

Advanced search form on results page doesn't have input fields filled, dropdown lists are empty, and if I try to search by "phrase search" I don't have any results from ezPublish, just from custom search. If I search using 'typical search' field I got both results, but dropdown list are stil empty.

I think that maybe my way is not exactly good.
Here's some code"

extension's php script (overview.php)

<?php
include_once( 'kernel/common/template.php' );
include_once( 'kernel/content/search.php' );

function arr_clean(&$val) {
   $val=chop(trim($val));
}

if(isset($_REQUEST["SearchText"]) && $_REQUEST["SearchText"]!=""){
	
	$searchArr=$_REQUEST["SearchText"];
	$searchArr=explode(" ",$searchArr);
	array_walk($searchArr,'arr_clean');

};

if(isset($_REQUEST["PhraseSearchText"]) && $_REQUEST["PhraseSearchText"]!=""){
	$searchArr=$_REQUEST["PhraseSearchText"];
}


$tpl =& templateInit();

    include_once( 'lib/ezdb/classes/ezpostgresqldb.php' );  
	$db =& eZDB::instance();
    $wynik =& $db->arrayQuery( 'SELECT prac.*, inst.*, dz.* FROM pracownik prac, instytut inst, dzial dz WHERE	prac.id_dzial=dz.id_dzial AND dz.id_inst=inst.id_inst ',
                            array( 'offset' => 0, 'limit' => 10 ) );

	$tpl->setVariable('wynik', $wynik);
	
	$Result = array();
	$Result['content'] =& $tpl->fetch( 'design:bw_search.tpl');
	//$Result['content'] =& $tpl->fetch( 'design:nikiss/overview.tpl' );
	$Result['path'] = array( array( 'url' => false,
                                'text' => 'Wynik wyszukiwania' ) );
                                
?>

bw_search.tpl is standard advancedsearch.tpl file and is called using link: mysite__web_address/ez/index.php/plain/przeszukaj_baze_wiedzy

I'm not sure if it can be done this way.

Aleksander

Aleksander Lech

Thursday 22 September 2005 3:26:09 am

Well....
of course it was my mistake.
A was including search.php and using advancedsearch.tpl. Changing include from search.php to advancedsearch.php made things work great.

Aleksander

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 18 2025 21:00:22
Script start
Timing: Jan 18 2025 21:00:22
Module start 'layout'
Timing: Jan 18 2025 21:00:22
Module start 'content'
Timing: Jan 18 2025 21:00:23
Module end 'content'
Timing: Jan 18 2025 21:00:23
Script end

Main resources:

Total runtime0.8274 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 589.1719152.6406
Module start 'layout' 0.00740.0028 741.812539.4766
Module start 'content' 0.01020.8158 781.2891430.8906
Module end 'content' 0.82600.0013 1,212.17978.1250
Script end 0.8274  1,220.3047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3827160.0002
Check MTime0.00130.1578160.0001
Mysql Total
Database connection0.00100.122210.0010
Mysqli_queries0.784194.7614520.0151
Looping result0.00050.0613500.0000
Template Total0.794396.020.3972
Template load0.00220.260020.0011
Template processing0.792195.738520.3961
Template load and register function0.00010.016710.0001
states
state_id_array0.00070.084110.0007
state_identifier_array0.00130.151620.0006
Override
Cache load0.00170.2085200.0001
Sytem overhead
Fetch class attribute can translate value0.00090.114010.0009
Fetch class attribute name0.00150.179120.0007
XML
Image XML parsing0.00010.015210.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00160.1913100.0002
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs