Search By Category Search By Category
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Search By Category

Started by will, March 21, 2007, 07:47:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

will

I was wondering weather anybody can help me on adding a search field on the main page with search by category or all categories, I mean adding a drop down menu where a member can select which category they want to search or select 'all categorys'

attached both images to show which ways I would like this search to work

Hope you understand

Thanks ;D

will


Joachim Müller

#2
It's pretty easy to come up with a search field on all pages that does the same thing the regular coppermine search page does. Searching by category isn't implemented in Coppermine's core though, so this is not a matter of coming up with the search form, but with a page that does the queries and comes up with the results. This is not a trivial task (in other words: this would require some coding skills and some time to actually code this). In my opinion this is beyond the scope of what you can expect from free support - it would more be a case for a paid customization request. That's probably the reason why nobody answered: there is no simple solution, and nobody is willing to look into this in detail.
If you're willing to pay for this, then read the sticky thread "sub-board rules, read first!" on the paid support board and do as suggested there (posting your budget and schedule). A moderator will then move this thread if applicable.

will


will

#4
I'm currently looking for someone to do me a customization of the search in coppermine on the main page with a drop down bar so users can select which category to search in or search in all categories.

I have a budget of £10-£20, if you think this not enough I'm willing to go to £25

I have also attached two pics to show what I need doing, taken from another site I use

Any help will be great ;D

Joachim Müller

I suggested to reply to the existing thread. That's why I told you that a moderator would move the thread if applicable. You were not suppossed to start a new thread, especially since the new thread you started will not explain to potential takers what the catch is. That's why I merged both threads into this one and stripped the attachments of your second posting.

SaWey

I've begun some coding around this feature in the past, but I have no time to finish this.

If someone want to use it....


<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.10
  $Source$
  $Revision: 1 $
  $Author: SaWey $
  Parts of this script where borrowed from the searchnew.php file written by gaugau.
  $Date: 2006-11-26 01:52:21  $
**********************************************/
define('IN_COPPERMINE'true);
define('SEARCH_PHP'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');

if (!
USER_ID && $CONFIG['allow_unlogged_access'] == 0) {
$redirect $redirect "login.php";
header("Location: $redirect");
exit();
}

if (isset(
$_POST['search'])){
search();
}else{
start();
}

function 
start(){

$cat_array = array();
getallcatsindb($cat_array);


/**
*Create the select box
*/
$form '
<form name="searchcpg" method="post" action="">
<input type="text" name="search" class="textinput"/>
<input type="hidden" name="album" value="search" />
<input type="hidden" name="title" value="title" />
<input type="hidden" name="caption" value="caption" />
<input type="hidden" name="keywords" value="keywords" />
<input type="hidden" name="owner_name" value="owner_name" />
<input type="hidden" name="filename" value="filename" />
<select name="album" size="1">
'
;
foreach($cat_array as $cat => $arr){
$form .= ' <option value="cat_' $cat '">'.$arr['name'].'</option>';
foreach($arr['albums'] as $key => $album){
$form .= ' <option value="alb_' $key '">&nbsp;&nbsp;&nbsp;- '.$album.'</option>';
}
}
$form .= '</select>';
$form .= '&nbsp;<input type="submit" value="' 'Search" />';//$lang_search_php['submit_search'] . '" />';
$form .= '</form>';
print($form);
}

function 
search(){

$album $_POST['album'];
if(substr($album,0,3)=="alb"){
//search in album
$album substr($album,4);

}else{
//search in category
$category substr($album,4);

}


}

/**
 * getallcatsindb()
 *
 * Fill an array with all albums where keys are aid of albums and values are
 * album title
 *
 * @param  $cat_array the array to be filled
 * @return
 */
function getallcatsindb(&$cat_array)
{
    global 
$CONFIG;

    
$cats_sql "SELECT cid, name " "FROM {$CONFIG['TABLE_CATEGORIES']} " "WHERE 1";
    
$cats_result cpg_db_query($cats_sql);

    while (
$cats_row mysql_fetch_array($cats_result)) {
        
$cat_array[$cats_row['cid']]['name'] = $cats_row['name'];
$cid $cats_row['cid'];
$album_sql "SELECT aid, title " "FROM {$CONFIG['TABLE_ALBUMS']} " "WHERE 1 AND category='$cid'";
//print($album_sql);
$album_result cpg_db_query($album_sql);

while ($album_row mysql_fetch_array($album_result)) {
$cat_array[$cats_row['cid']]['albums'][$album_row['aid']]=$album_row['title'];
}
mysql_free_result($album_result);
    }
    
mysql_free_result($cats_result);
}
?>


will

@GauGau: Sorry I didn't read the reply from you properly

@SaWey: Thanks for the code this will be great for whoever will take this request

If anyone can help, please email me and I will send the relevant files needed ;D

will

Is there anybody willing to help, need this doing a.s.a.p.

Anybody interested let me know ;D

will

Still need someone to help me on this and take this request

Please email me will.taka05@googlemail.com for info ;D

Joachim Müller

Quote from: GauGau on November 15, 2006, 11:02:34 PM
It is not advisable to post your email address in your thread - this will only make email harvesters store your email address, resulting in even more spam. Just enable notifictions for the thread you start instead. You'll be emailed then if potential job takers reply to your thread.