PEAK XOOPS - Add a search function in englishin japanese

Add a search function

  • You cannot open a new topic into this forum
  • Guests cannot post into this forum
Previous post - Next post | Parent - Children.1 .2 | Posted on 2004/11/7 14:26
flyaway  Private   Posts: 7
Is it possible to add a search function in piCal? when the event more and more, we should have a search function, then we can find data quickly.
Votes:0 Average:0.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/11/10 12:26
GIJOE  Gunnery Sergeant   Posts: 4110
hi flyaway.

Do you know "search" of XOOPS?
Since I implemented global search function into piCal, you can find events by using "search box".
Votes:0 Average:0.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/1 23:05
flyaway  Private   Posts: 7
Sorry... since i am a newbie of xoops, pardon for this stupid question.
Votes:0 Average:0.00
Previous post - Next post | Parent - No child | Posted on 2004/12/9 10:10
Lordliquid  Private   Posts: 2
Actually.. The thing I would like it to "search" for is the poster. "Search by Username". could you make this possible? thank you.
Votes:0 Average:0.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/9 10:35
Lordliquid  Private   Posts: 2
what im looking for is maybe a search in my album-p module for username, that allows u to search for pictures posted by the user.
Votes:0 Average:0.00
Previous post - Next post | Parent - No child | Posted on 2004/12/9 17:10
GIJOE  Gunnery Sergeant   Posts: 4110
replace include/search.inc.php
<?php

if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;

$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
if( ! preg_match( '/^myalbum\d*$/' , $mydirname ) ) die ( "invalid dirname of myalbum: " . htmlspecialchars( $mydirname ) ) ;


eval( '

function '.$mydirname.'_search( $keywords , $andor , $limit , $offset , $userid )
{
	global $xoopsDB ;

	include( XOOPS_ROOT_PATH."/modules/'.$mydirname.'/include/read_configs.php" ) ;

	$sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,t.description FROM $table_photos l LEFT JOIN $table_text t ON t.lid=l.lid LEFT JOIN ".$xoopsDB->prefix("users")." u ON l.submitter=u.uid WHERE status>0" ;

	if( $userid > 0 ) {
		$sql .= " AND l.submitter=".$userid." ";
	}

	$whr = "" ;
	if( is_array( $keywords ) && count( $keywords ) > 0 ) {
		$whr = "AND (" ;
		switch( strtolower( $andor ) ) {
			case "and" :
				foreach( $keywords as $keyword ) {
					$whr .= "CONCAT(l.title,\' \',t.description,\' \',u.uname) LIKE \'%$keyword%\' AND " ;
				}
				$whr = substr( $whr , 0 , -5 ) ;
				break ;
			case "or" :
				foreach( $keywords as $keyword ) {
					$whr .= "CONCAT(l.title,\' \',t.description,\' \',u.uname) LIKE \'%$keyword%\' OR " ;
				}
				$whr = substr( $whr , 0 , -4 ) ;
				break ;
			default :
				$whr .= "CONCAT(l.title,\'  \',t.description,\' \',u.uname) LIKE \'%{$keywords[0]}%\'" ;
				break ;
		}
		$whr .= ")" ;
	}

	$sql = "$sql $whr ORDER BY l.date DESC";
	$result = $xoopsDB->query( $sql , $limit , $offset ) ;
	$ret = array() ;
 	while( $myrow = $xoopsDB->fetchArray($result) ) {
		$ret[] = array(
			"image" => "images/pict.gif" ,
			"link" => "photo.php?lid=".$myrow["lid"] ,
			"title" => $myrow["title"] ,
			"time" => $myrow["date"] ,
			"uid" => $myrow["submitter"]
		) ;
	}
	return $ret;
}

' ) ;

?>
This code is a part of next version.
Votes:0 Average:0.00

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!