Cara menambah kolom pencarian pada pencarian lanjut ( advance search ) pada SLiMS

Halo Halo, kamu lagi pengen nambahin kolom pencarian tambahan pada advance search SLiMS? yup, memang ada beberapa bagian yang belum dikeluarkan pada tempalte default SLiMS, kalau mau modif ya ayo aja.

ini tampilan advance search default pada tempalte classic

advance search classic

Oke kita mau menambahkan kolom pencaraian Tipe Media, Bahasa,

Oke berikut langkahnya :

  1. Buka File advsearch.php di slimsroot/template/classic/part/content
    Tambahkan script dibawah ini
    <!– Multiple advance search by Erwan Setyo Budi START –>

    </div>

    </div>

    </div>

    </div>
    <!– Multiple advance search by Erwan Setyo Budi END –>

  2. Lalu Simpan, selanjutnya buka file biblio_list.inc.php di slimsroot/lib
    tambahkan di sekitar baris 31
    class biblio_list extends biblio_list_model {
    protected $searchable_fields = array(‘title’, ‘author’, ‘subject’, ‘isbn’,
    ‘publisher’, ‘gmd’, ‘notes’, ‘colltype’, ‘publishyear’,
    ‘location’, ‘itemcode’, ‘callnumber’, ‘itemcallnumber’, ‘notes’,’media’,’content’,’language’,’frequency’);
    protected $field_join_type = array(‘title’ => ‘OR’, ‘author’ => ‘OR’, ‘subject’ => ‘OR’);

    lalu tambahkan di sekitar baris 116

    } elseif ($_field == ‘media’) { // modified by drajat
    if (strlen($_q) < 4) {

    $_sql_criteria .= ” biblio.media_type_id = ‘$_q’ “;
    $_title_buffer = ”;
    }
    } elseif ($_field == ‘content’) { // modified by drajat
    if (strlen($_q) < 4) {

    $_sql_criteria .= ” biblio.content_type_id = ‘$_q’ “;
    $_title_buffer = ”;
    }
    } elseif ($_field == ‘language’) { // modified by drajat
    if (strlen($_q) < 4) {

    $_sql_criteria .= ” biblio.language_id = ‘$_q’ “;
    $_title_buffer = ”;
    }
    } elseif ($_field == ‘frequency’) { // modified by drajat
    if (strlen($_q) < 4) {

    $_sql_criteria .= ” biblio.frequency_id = ‘$_q’ “;
    $_title_buffer = ”;
    }

    simpan

  3. Lalu buka file common.php di slimsroot/lib/contents
    Tambahkan script dibah ini di sekitar baris 57

    /* Type Media By Drajat*/
    ob_start();
    echo ‘<option value=”0″>’.__(‘Media’).'</option>’;
    $med_q = $dbs->query(‘SELECT id,media_type FROM mst_media_type’);
    while ($med_d = $med_q->fetch_row()) {
    echo ‘<option value=”‘.$med_d[0].'”>’.$med_d[1].'</option>’;
    }
    $med_list = ob_get_clean();

    ob_start();
    echo ‘<option value=”0″>’.__(‘Content’).'</option>’;
    $cont_q = $dbs->query(‘SELECT id,content_type FROM mst_content_type’);
    while ($cont_d = $cont_q->fetch_row()) {
    echo ‘<option value=”‘.$cont_d[0].'”>’.$cont_d[1].'</option>’;
    }
    $cont_list = ob_get_clean();

    ob_start();
    echo ‘<option value=”0″>’.__(‘Language’).'</option>’;
    $lang_q = $dbs->query(‘SELECT language_id,language_name FROM mst_language’);
    while ($lang_d = $lang_q->fetch_row()) {
    echo ‘<option value=”‘.$lang_d[0].'”>’.$lang_d[1].'</option>’;
    }
    $lang_list = ob_get_clean();

    ob_start();
    echo ‘<option value=”0″>’.__(‘Frequency’).'</option>’;
    $freq_q = $dbs->query(‘SELECT frequency_id,frequency FROM mst_frequency’);
    while ($freq_d = $freq_q->fetch_row()) {
    echo ‘<option value=”‘.$freq_d[0].'”>’.$freq_d[1].'</option>’;
    }
    $freq_list = ob_get_clean();

    /* Language selection list */
    ob_start();
    require_once(LANG.’localisation.php’);
    foreach ($available_languages AS $lang_index) {
    $selected = null;
    $lang_code = $lang_index[0];
    $lang_name = $lang_index[1];
    if ($lang_code == $sysconf[‘default_lang’]) {
    $selected = ‘selected’;
    }
    echo ‘<option value=”‘.$lang_code.'” ‘.$selected.’>’.$lang_name.'</option>’;
    }
    $language_select = ob_get_clean();

    lalu simpan

  4. Lanjut, buka file default.inc.php di slimsroot/lib/contents
    ubah baris 119-207 menjadi :
    $media = ”;
    if (isset($_GET[‘media’])) { // modified by drajat
    $media = trim(strip_tags(urldecode($_GET[‘media’])));
    }
    $content = ”;
    if (isset($_GET[‘content’])) { // modified by drajat
    $content = trim(strip_tags(urldecode($_GET[‘content’])));
    }
    $language = ”;
    if (isset($_GET[‘language’])) { // modified by drajat
    $language = trim(strip_tags(urldecode($_GET[‘language’])));
    }
    $frequency = ”;
    if (isset($_GET[‘frequency’])) { // modified by drajat
    $frequency = trim(strip_tags(urldecode($_GET[‘frequency’])));
    }
    // don’t do search if all search field is empty
    if ($title || $author || $subject || $isbn || $gmd || $colltype || $location || $publisher || $callnumber || $media || $content || $language || $frequency) {
    $criteria = ”;
    if ($title) { $criteria .= ‘ title=’.$title; }
    if ($author) { $criteria .= ‘ author=’.$author; }
    if ($subject) { $criteria .= ‘ subject=’.$subject; }
    if ($isbn) { $criteria .= ‘ isbn=’.$isbn; }
    if ($gmd) { $criteria .= ‘ gmd=”‘.$gmd.'”‘; }
    if ($colltype) { $criteria .= ‘ colltype=”‘.$colltype.'”‘; }
    if ($location) { $criteria .= ‘ location=”‘.$location.'”‘; }
    if ($publisher) { $criteria .= ‘ publisher=”‘.$publisher.'”‘; }
    if ($callnumber) { $criteria .= ‘ callnumber=”‘.$callnumber.'”‘; }
    if ($media) { $criteria .= ‘ media=”‘.$media.'”‘; } // modifed by drajat
    if ($content) { $criteria .= ‘ content=”‘.$content.'”‘; } // modifed by drajat
    if ($language) { $criteria .= ‘ language=”‘.$language.'”‘; } // modifed by drajat
    if ($frequency) { $criteria .= ‘ frequency=”‘.$frequency.'”‘; } // modifed by drajat
    $criteria = trim($criteria);
    $biblio_list->setSQLcriteria($criteria);
    }
    }

    // searched words
    $searched_words = implode(‘ ‘, $biblio_list->words);
    if ($biblio_list->words) {
    $searched_words_js_array = ‘[‘;
    foreach($biblio_list->words as $word) {
    $searched_words_js_array .= “‘$word’,”;
    }
    $searched_words_js_array = substr_replace($searched_words_js_array, ”, -1);
    $searched_words_js_array .= ‘]’;
    }

    // search result info construction
    $keywords_info = ‘<span class=”search-keyword-info” title=”‘.htmlentities($keywords).'”>’.((strlen($keywords)>30)?substr($keywords, 0, 30).’…’:$keywords).'</span>’;
    $search_result_info .= ‘

    ‘;
    // Media
    ob_start();
    $sp_d = $dbs->query(“SELECT b.media_type_id,mt.id,mt.media_type FROM biblio AS b LEFT JOIN mst_media_type AS mt ON mt.id=b.media_type_id WHERE b.media_type_id=”.$media.””);
    $sp_data = $sp_d->fetch_assoc();
    ob_get_clean();
    // Content
    ob_start();
    $ct_d = $dbs->query(“SELECT b.content_type_id,ct.id,ct.content_type FROM biblio AS b LEFT JOIN mst_content_type AS ct ON ct.id=b.content_type_id WHERE b.content_type_id=”.$content.””);
    $ct_data = $ct_d->fetch_assoc();
    ob_get_clean();

    ob_start();
    $f_d = $dbs->query(“SELECT b.frequency_id,f.frequency_id,f.frequency FROM biblio AS b LEFT JOIN mst_frequency AS f ON f.frequency_id=b.frequency_id WHERE b.frequency_id=”.$frequency.””);
    $f_data = $f_d->fetch_assoc();
    ob_get_clean();

    if ($is_adv) {
    $search_result_info .= __(‘Found {biblio_list->num_rows} from your keywords’).’: ‘.$keywords_info.’ ‘;
    if ($title) { $search_result_info .= ‘Judule Jon : ‘.$title.’, ‘; }
    if ($author) { $search_result_info .= ‘Author : ‘.$author.’, ‘; }
    if ($subject) { $search_result_info .= ‘Subject : ‘.$subject.’, ‘; }
    if ($isbn) { $search_result_info .= ‘ISBN/ISSN : ‘.$isbn.’, ‘; }
    if ($gmd) { $search_result_info .= ‘GMD : ‘.$gmd.’, ‘; }
    if ($colltype) { $search_result_info .= ‘Collection Type : ‘.$colltype.’, ‘; }
    if ($location) { $search_result_info .= ‘Location : ‘.$location.’, ‘; }
    if ($publisher) { $search_result_info .= ‘Publisher : ‘.$publisher.’, ‘; }
    if ($callnumber) { $search_result_info .= ‘Call Number : ‘.$callnumber.’, ‘; }
    if ($media) { $search_result_info .= ‘Mediane Jon : ‘.$sp_data[‘media_type’].’, ‘; }
    if ($content) { $search_result_info .= ‘Konten Jon : ‘.$ct_data[‘content_type’].’, ‘; }
    if ($language) { $search_result_info .= ‘Bahasane Jon : ‘.$language.’, ‘; }
    if ($frequency) { $search_result_info .= ‘Frekuensine Jon : ‘.$f_data[‘frequency’].’, ‘; }
    // strip last comma
    $search_result_info = substr_replace($search_result_info, ”, -2);
    } else {
    $search_result_info .= __(‘Found {biblio_list->num_rows} from your keywords’).’: ‘.$keywords_info.’‘;
    }
    $search_result_info .= ‘

    ‘;

  5. SELESAI,

Hasil Akhir :
hasil akhir advance search

Mumet Thoo? kandani oq, nih file jadi nya , uda saya tandain yg di ubah. Kalo ga isa WA boleh disini 🙂

Source via google drive

https://drive.google.com/file/d/1DRAb_e9noKfguxYFoR7WBQqDOK3ziQan/view?usp=sharing

 

 

0 comments on “Cara menambah kolom pencarian pada pencarian lanjut ( advance search ) pada SLiMS

Leave a Reply

Your email address will not be published. Required fields are marked *