Page 1 of 1

[SOLVED] CTL Module Maker - Search results show twice

Posted: Sat Feb 20, 2010 2:22 pm
by stijlXpres
Hi,

I've got a strange problem. I'm using CTL Module Maker, latest version, and use the internal search function.
Now I've got the strange thing that (no matter what keyword I use) the results show up twice.
As if somewhere the results are triggered to show two times.

The URL: http://dev.vikingentertainment-raalte.n ... ertainment

Can anyone tell me what I'm doing wrong?

Re: CTL Module Maker - Search results show twice

Posted: Sun Feb 21, 2010 10:00 am
by klenkes
I'm sorry not to be of any help in this matter, but I too found out about this bug just a few days ago and couldn't find a fix for it.
At least you know it's not related to your own module but a CTLMM problem.

--
Bernd

Re: CTL Module Maker - Search results show twice

Posted: Thu Mar 18, 2010 5:13 am
by kank
I've had the same problem. FYI I've submitted a bug report here

Re: CTL Module Maker - Search results show twice

Posted: Sun Mar 21, 2010 11:38 pm
by kank
I should have included the following version numbers too:

I'm using:
CMSMS Version
1.6.7

CTLModuleMaker
1.8.9.3

Re: CTL Module Maker - Search results show twice

Posted: Tue Mar 23, 2010 2:41 am
by kank
OK, I'm having some success here.

I've managed to fix the problem by editing /modules/yourmodulename/action.search.php  and changing this code ...

Code: Select all

	if(count($itemlist) == 0 && $emptytemplate != "**"){
		echo $this->ProcessTemplateFromDatabase($emptytemplate);				
	}elseif($template == FALSE){
		echo $this->ProcessTemplate("search_generalresults.tpl");
	}else{
		echo $this->ProcessTemplateFromData($template);
	}
To this...

Code: Select all

	if(count($itemlist) == 0 && $emptytemplate = "**"){
		echo $this->ProcessTemplateFromData($template);
	}
My kludge probably buggers something else ::) but if it does, I haven't found it yet!

Re: CTL Module Maker - Search results show twice

Posted: Sun Jun 13, 2010 4:17 pm
by nervino
Hi Kank, I had the same problem and I tried your workaround, but the template was still printed twice in a search result with 0 (zero) item.

I think that the issue is due to the position of the code that prints out the template, which is inside the foreach level loop ( foreach($levels as $level) )

So, I changed the code in this way and it works for me:


Code: Select all

foreach($levels as $level){
	$whereclause = "";
	$fields = $this->get_levelsearchfields($level);
	$keywords = $this->parsekeywords(html_entity_decode($params["searchfield"]));
	foreach($fields as $field){
	foreach($keywords as $keyword){
					$whereclause .= ($whereclause == ""?"":" OR ")."A.".$field." LIKE '%".addslashes($keyword)."%'";
				}
			}
			$whereclause = "A.active=1".($whereclause == ""?"":" AND (".$whereclause.")");
			$getfunction = "get_level_".$level;
			$itemlist = $this->$getfunction(array(), false, "", "", isset($params["orderby"])?$params["orderby"]:0, $limit, $whereclause);
			$this->smarty->assign("itemcount",count($itemlist));
			
			if(count($itemlist) > 0){

				$total = $nbperpage?$this->countsomething($level,"id",array(),$whereclause, array()):false;
				$this->paginate($what,$total,$id,$returnid,$params,"search");
				
				// we must build a detail link for each result element
				$newlist = array();
				foreach($itemlist as $item){
					$item = $this->addfrontendurls($item,$params,$id,$linkreturnid);
					$item->is_selected = false;
					array_push($newlist, $item);
				}
				$this->smarty->assign("itemlist",$newlist);
				$this->smarty->assign("leveltitle",$this->Lang($level."_plural"));
				
				/* COMMENTED OUT
																
				if($template == FALSE){
					echo $this->ProcessTemplate("search_generalresults.tpl");
				}else{
					echo $this->ProcessTemplateFromData($template);				
				}
				*/
			}else{
				$this->paginate($what,0,$id,$returnid,$params,"search");
				$this->smarty->assign("itemlist",$itemlist);
				$this->smarty->assign("error_msg",$this->Lang("error_noitemfound"));
				}
				
			/* COMMENTED OUT
			if(count($itemlist) == 0 && $emptytemplate != "**"){
				echo $this->ProcessTemplateFromDatabase($emptytemplate);		
			}elseif($template == FALSE){
				echo $this->ProcessTemplate("search_generalresults.tpl");
			}else{
				echo $this->ProcessTemplateFromData($template);
			}
			*/
		}

		// MOVED OUTSIDE foreach($levels as $level) LOOP

		if(count($itemlist) == 0 && $emptytemplate != "**"){
				echo $this->ProcessTemplateFromDatabase($emptytemplate);		
			  }elseif($template == FALSE){
				echo $this->ProcessTemplate("search_generalresults.tpl");
			}else{
				echo $this->ProcessTemplateFromData($template);
			}
		
	}
	
	// # END SEARCH RESULTS
	// 

Re: CTL Module Maker - Search results show twice

Posted: Sun Jun 13, 2010 4:41 pm
by stijlXpres
When I combine the solutions of both Nervino & Kank it works for me. The topic seems to be solved!