|
Personnaliser les résultats de la recherche avec un template |
|
Xoops accro
Inscrit: 04/02/2003 01:54
De Le Mans
|
C'est en anglais, mais pour ceux que cela intéresse, une solution a été fournie dans cette faq.
Posté le : 30/07/2007 21:58
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Guest_
|
B'soir, Si c'est vraiment cela qu'on peut obtenir, je m'y colle de suite !! @+
Posté le : 30/07/2007 22:14
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Semi pro
Inscrit: 13/12/2004 11:28
De Lyon
|
Bonsoir, Hum, je sens que je vais intégrer ca dans un ptit module
Posté le : 30/07/2007 22:27
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Guest_
|
J'y pensais également... Je vais faire les fichiers hackés et je te les transmets ! @Bientôt
Posté le : 30/07/2007 22:38
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Semi pro
Inscrit: 13/12/2004 11:28
De Lyon
|
Burning qui se met a hacké Xoops, mais que se passe t'il
Posté le : 30/07/2007 22:47
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Guest_
|
J'ai dis "je m'y colle" ... restons optimiste : livraison prévue avant la xoops 2.0.17 !
Posté le : 30/07/2007 23:28
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Semi pro
Inscrit: 01/08/2005 19:06
|
ouaaaaa qu'elle effet superbe si j'ai tous compris en bas du fichier searchform.php je modifie et je met ceci Citation :$search_form->addElement(new XoopsFormButton("", "submit", _SR_SEARCH, "submit"));
return $search_form->render(); // Added by Lankford on 2007/7/26. ?> ensuite dans modules/system/xoops_version.php je rajoute ceci au dessus de //blocks Citation :$modversion['templates'][15]['description'] = 'Dummy template for custom blocks or blocks without templates'; $modversion['templates'][16]['file'] = 'system_search.html'; $modversion['templates'][16]['description'] = 'Smarty template for Xoops\' search page.';
// Blocks ensuite il faut creer un smarty dans un fichier appeler system_search.html que je mais dans le dossier \modules\system\templates\ donc je mais sa dans ce nouveau fichier Citation :<!-- Added by Lankford on 2007/7/26 -->
<h3>"<{$search_type}>" <{$label_search_results}>: <{$showing}></h3> <{$label_keywords}> <strong> <{* This section generates a space separated list of keywords that were searched. *}> <{section name=cur_kw_searched loop=$searched_keywords}> <{$searched_keywords[cur_kw_searched]}><{if $smarty.section.cur_kw_searched.index <> $smarty.section.cur_kw_searched.total}> <{/if}> <{/section}> </strong> <br /> <{$label_ignored_keywords}> <strong> <{* This section generates a space separated list of keywords that were NOT searched. *}> <{section name=cur_kw_not_searched loop=$ignored_keywords}> <{$ignored_keywords[cur_kw_not_searched]}><{if $smarty.section.cur_kw_not_searched.index <> $smarty.section.cur_kw_not_searched.total}> <{/if}> <{/section}> </strong> <br />
<{* This section generates a search results that mimic Xoops' original search.php results. Note: The results are sorted. Modules with higher hit counts are located on the page above modules with lower hit counts. *}> <{* This section has been commented out in favor of the 'table' version located below... <{foreach from=$module_sort_order key=sort_key item=sort_value}> <h3><{$sort_key}>: (<{$sort_value}> hits returned)</h3> <{section name=cur_result loop=$search_results[$sort_key].results}> <{if $smarty.section.cur_result.index > 0}><br /><{/if}> <img alt="<{$search_results[$sort_key].results[cur_result].processed_image_alt_text}>" src="<{$search_results[$sort_key].results[cur_result].processed_image_url}>" /> <{$search_results[$sort_key].results[cur_result].processed_image_tag}> <b> <a href="<{$search_results[$sort_key].results[cur_result].link}>"><{$search_results[$sort_key].results[cur_result].processed_title}></a> </b> <br /><small> <a href="<{$search_results[$sort_key].results[cur_result].processed_user_url}>"><{$search_results[$sort_key].results[cur_result].processed_user_name}></a> <{$search_results[$sort_key].results[cur_result].processed_time}> </small> <{/section}> <br /> <a href="<{$search_results[$sort_key].search_more_url}>"><{$search_results[$sort_key].search_more_title}></a> <{/foreach}>
<hr /> *}>
<{* This section generates a search results and places them into tables using the standard Xoops style tags for table formatting. Note: The results are sorted. Modules with higher hit counts are located on the page above modules with lower hit counts. *}> <{foreach from=$module_sort_order key=sort_key item=sort_value}> <table class="outer" cellpadding="4" cellspacing="1" width="100%"> <tr> <th colspan="2" align="left" class="head"> <b><{$sort_key}></b>: (<{$sort_value}> hits returned) </th> </tr> <{if ($search_results[$sort_key].search_more_title == '') and ($sort_value > 0)}> <tr> <th colspan="2"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="left"> <a href="<{$search_results[$sort_key].search_prev_url}>"><{$search_results[$sort_key].search_prev_title}></a> </td> <td align="right"> <a href="<{$search_results[$sort_key].search_next_url}>"><{$search_results[$sort_key].search_next_title}></a> </td> </tr> </table> </th> </tr> <{/if}> <{section name=cur_result loop=$search_results[$sort_key].results}> <tr> <td class="head"> <{math equation="x + y" x=$smarty.section.cur_result.index y=$start}> </td> <td align="left" class="<{cycle values="even,odd"}>" width="100%"> <img alt="<{$search_results[$sort_key].results[cur_result].processed_image_alt_text}>" src="<{$search_results[$sort_key].results[cur_result].processed_image_url}>" /> <{$search_results[$sort_key].results[cur_result].processed_image_tag}> <b> <a href="<{$search_results[$sort_key].results[cur_result].link}>"><{$search_results[$sort_key].results[cur_result].processed_title}></a> </b> <br /><small> <a href="<{$search_results[$sort_key].results[cur_result].processed_user_url}>"><{$search_results[$sort_key].results[cur_result].processed_user_name}></a> <{$search_results[$sort_key].results[cur_result].processed_time}> </small> </td> </tr> <{/section}> <{if $sort_value > 0 }> <{if $search_results[$sort_key].search_more_title == ''}> <tr> <th colspan="2" align="right"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="left"> <a href="<{$search_results[$sort_key].search_prev_url}>"><{$search_results[$sort_key].search_prev_title}></a> </td> <td align="right"> <a href="<{$search_results[$sort_key].search_next_url}>"><{$search_results[$sort_key].search_next_title}></a> </td> </tr> </table> </th> </tr> <{else}> <{if $search_results[$sort_key].search_more_url != ''}> <tr> <th colspan="2" align="right"> <a href="<{$search_results[$sort_key].search_more_url}>"><{$search_results[$sort_key].search_more_title}></a> </th> </tr> <{/if}> <{/if}> <{/if}> </table> <br /> <{/foreach}>
<hr /> <{$search_form}> ensuite dans search.php qui ce trouve a la racine je modifie et je remplace tous le code par celui ci Citation :<?php // $Id: search.php 506 2006-05-26 23:10:37Z skalpa $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // // <http://www.xoops.org/> // // ------------------------------------------------------------------------ // // 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. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ //
$xoopsOption['pagetype'] = "search";
include 'mainfile.php';
$xoopsOption['template_main'] = 'system_search.html';
$config_handler =& xoops_gethandler('config'); $xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH);
if ($xoopsConfigSearch['enable_search'] != 1) { header('Location: '.XOOPS_URL.'/index.php'); exit(); }
include XOOPS_ROOT_PATH.'/header.php';
$action = "search"; if (!empty($_GET['action'])) { $action = $_GET['action']; } elseif (!empty($_POST['action'])) { $action = $_POST['action']; } $query = ""; if (!empty($_GET['query'])) { $query = $_GET['query']; } elseif (!empty($_POST['query'])) { $query = $_POST['query']; } $andor = "AND"; if (!empty($_GET['andor'])) { $andor = $_GET['andor']; } elseif (!empty($_POST['andor'])) { $andor = $_POST['andor']; } $mid = $uid = $start = 0; if ( !empty($_GET['mid']) ) { $mid = intval($_GET['mid']); } elseif ( !empty($_POST['mid']) ) { $mid = intval($_POST['mid']); } if (!empty($_GET['uid'])) { $uid = intval($_GET['uid']); } elseif (!empty($_POST['uid'])) { $uid = intval($_POST['uid']); } if (!empty($_GET['start'])) { $start = intval($_GET['start']); } elseif (!empty($_POST['start'])) { $start = intval($_POST['start']); }
$xoopsTpl->assign("start", $start + 1);
$queries = array();
if ($action == "recoosults") { if ($query == "") { redirect_header("search.php",1,_SR_PLZENTER); exit(); } } elseif ($action == "showall") { if ($query == "" || empty($mid)) { redirect_header("search.php",1,_SR_PLZENTER); exit(); } } elseif ($action == "showallbyuser") { if (empty($mid) || empty($uid)) { redirect_header("search.php",1,_SR_PLZENTER); exit(); } }
$groups = is_object($xoopsUser) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS; $gperm_handler = & xoops_gethandler( 'groupperm' ); $available_modules = $gperm_handler->getItemIds('module_read', $groups);
if ($action == 'search') { // This area seems to handle the 'just display the advanced search page' part. $search_form = include 'include/searchform.php'; $xoopsTpl->assign('search_form', $search_form); include XOOPS_ROOT_PATH.'/footer.php'; exit(); }
if ( $andor != "OR" && $andor != "exact" && $andor != "AND" ) { $andor = "AND"; } $xoopsTpl->assign("search_type", $andor);
$myts =& MyTextSanitizer::getInstance(); if ($action != 'showallbyuser') { if ( $andor != "exact" ) { $ignored_queries = array(); // holds kewords that are shorter than allowed minmum length $temp_queries = preg_split('/[\s,]+/', $query); foreach ($temp_queries as $q) { $q = trim($q); if (strlen($q) >= $xoopsConfigSearch['keyword_min']) { $queries[] = $myts->addSlashes($q); } else { $ignored_queries[] = $myts->addSlashes($q); } } if (count($queries) == 0) { redirect_header('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); exit(); } } else { $query = trim($query); if (strlen($query) < $xoopsConfigSearch['keyword_min']) { redirect_header('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); exit(); } $queries = array($myts->addSlashes($query)); } } $xoopsTpl->assign("label_search_results", _SR_SEARCHRESULTS);
// Keywords section. $xoopsTpl->assign("label_keywords", _SR_KEYWORDS . ':'); $keywords = array(); $ignored_keywords = array(); foreach ($queries as $q) { $keywords[] = htmlspecialchars(stripslashes($q)); } if (!empty($ignored_queries)) { $xoopsTpl->assign("label_ignored_keywords", sprintf(_SR_IGNOREDWORDS, $xoopsConfigSearch['keyword_min'])); foreach ($ignored_queries as $q) { $ignored_keywords[] = htmlspecialchars(stripslashes($q)); } $xoopsTpl->assign("ignored_keywords", $ignored_keywords); } $xoopsTpl->assign("searched_keywords", $keywords);
$all_results = array(); $all_results_counts = array(); switch ($action) { case "results": $module_handler =& xoops_gethandler('module'); $criteria = new CriteriaCompo(new Criteria('hassearch', 1)); $criteria->add(new Criteria('isactive', 1)); $criteria->add(new Criteria('mid', "(".implode(',', $available_modules).")", 'IN')); $modules =& $module_handler->getObjects($criteria, true); $mids = isset($_REQUEST['mids']) ? $_REQUEST['mids'] : array(); if (empty($mids) || !is_array($mids)) { unset($mids); $mids = array_keys($modules); } foreach ($mids as $mid) { $mid = intval($mid); if ( in_array($mid, $available_modules) ) { $module =& $modules[$mid]; $results =& $module->search($queries, $andor, 5, 0); $xoopsTpl->assign("showing", sprintf(_SR_SHOWING, 1, 5)); $count = count($results); $all_results_counts[$module->getVar('name')] = $count;
if (!is_array($results) || $count == 0) { $all_results[$module->getVar('name')] = array(); } else { for ($i = 0; $i < $count; $i++) { $results[$i]['processed_image_alt_text'] = $myts->makeTboxData4Show($module->getVar('name')) . ": "; if (isset($results[$i]['image']) && $results[$i]['image'] != "") { $results[$i]['processed_image_url'] = "modules/" . $module->getVar('dirname') . "/" . $results[$i]['image']; } else { $results[$i]['processed_image_url'] = "images/icons/posticon2.gif"; } if (!preg_match("/^http[s]*:\/\//i", $results[$i]['link'])) { $results[$i]['link'] = "modules/".$module->getVar('dirname')."/".$results[$i]['link']; } $results[$i]['processed_title'] = $myts->makeTboxData4Show($results[$i]['title']); $results[$i]['uid'] = @intval($results[$i]['uid']); if ( !empty($results[$i]['uid']) ) { $uname = XoopsUser::getUnameFromId($results[$i]['uid']); $results[$i]['processed_user_name'] = $uname; $results[$i]['processed_user_url'] = XOOPS_URL."/userinfo.php?uid=".$results[$i]['uid']; } $results[$i]['processed_time'] = !empty($results[$i]['time']) ? " (". formatTimestamp(intval($results[$i]['time'])).")" : ""; } if ( $count >= 5 ) { $search_url = XOOPS_URL.'/search.php?query='.urlencode(stripslashes(implode(' ', $queries))); $search_url .= "&mid=$mid&action=showall&andor=$andor"; } else { $search_url = ""; } $all_results[$module->getVar('name')] = array("search_more_title" => _SR_SHOWALLR, "search_more_url" => htmlspecialchars($search_url), "search_next_title" => "", "search_next_url" => "", "search_prev_title" => "", "search_prev_url" => "", "results" =>$results); } } unset($results); unset($module); } break; case "showall": case 'showallbyuser': $module_handler =& xoops_gethandler('module'); $module =& $module_handler->get($mid); $results =& $module->search($queries, $andor, 20, $start, $uid); $xoopsTpl->assign("showing", sprintf(_SR_SHOWING, $start + 1, $start + 20)); $count = count($results); $all_results_counts[$module->getVar('name')] = $count; if (is_array($results) && $count > 0) { $next_results =& $module->search($queries, $andor, 1, $start + 20, $uid); $next_count = count($next_results); $has_next = false;
if (is_array($next_results) && $next_count == 1) { $has_next = true; }
for ($i = 0; $i < $count; $i++) { $results[$i]['processed_image_alt_text'] = $myts->makeTboxData4Show($module->getVar('name')) . ": "; if (isset($results[$i]['image']) && $results[$i]['image'] != "") { $results[$i]['processed_image_url'] = "modules/" . $module->getVar('dirname') . "/" . $results[$i]['image']; } else { $results[$i]['processed_image_url'] = "images/icons/posticon2.gif"; } if (!preg_match("/^http[s]*:\/\//i", $results[$i]['link'])) { $results[$i]['link'] = "modules/".$module->getVar('dirname')."/".$results[$i]['link']; } $results[$i]['processed_title'] = $myts->makeTboxData4Show($results[$i]['title']); $results[$i]['uid'] = @intval($results[$i]['uid']); if ( !empty($results[$i]['uid']) ) { $uname = XoopsUser::getUnameFromId($results[$i]['uid']); $results[$i]['processed_user_name'] = $uname; $results[$i]['processed_user_url'] = XOOPS_URL."/userinfo.php?uid=".$results[$i]['uid']; } $results[$i]['processed_time'] = !empty($results[$i]['time']) ? " (". formatTimestamp(intval($results[$i]['time'])).")" : ""; } $search_url_prev = ""; $search_url_next = ""; $search_url = XOOPS_URL.'/search.php?query='.urlencode(stripslashes(implode(' ', $queries))); $search_url .= "&mid=$mid&action=$action&andor=$andor"; if ($action=='showallbyuser') { $search_url .= "&uid=$uid"; } if ( $start > 0 ) { $prev = $start - 20; $search_url_prev = $search_url."&start=$prev"; } if (false != $has_next) { $next = $start + 20; $search_url_next = $search_url."&start=$next"; } $all_results[$module->getVar('name')] = array("search_more_title" => "", "search_more_url" => "", "search_next_title" => _SR_NEXT, "search_next_url" => htmlspecialchars($search_url_next), "search_prev_title" => _SR_PREVIOUS, "search_prev_url" => htmlspecialchars($search_url_prev), "results" =>$results); } else { echo '<p>'._SR_NOMATCH.'</p>'; } break; } arsort($all_results_counts); $xoopsTpl->assign("module_sort_order", $all_results_counts); $xoopsTpl->assign("search_results", $all_results);
$search_form = include 'include/searchform.php'; $xoopsTpl->assign('search_form', $search_form);
include XOOPS_ROOT_PATH."/footer.php"; ?> enfin je mais à jour le module systéme depuis la parti admin et le tour et jouer est ce que j'ai bien tous compris ??
Posté le : 30/07/2007 23:47
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Guest_
|
Vi t'as tout compris : suffit de faire des copiés-collés (c'est déjà en place ici) ... fier comme s'il avait un bar-tabac le Burning Merci à Christian d'avoir extrait ce topic et à rlankford pour le hack ! @+
Posté le : 31/07/2007 00:15
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Semi pro
Inscrit: 01/08/2005 19:06
|
heu sa n'a rien a voir avec le lien que tu a donner burning les effet sont pas les méme que le deuxiéme post de ce sujet si je ne trompe?
Posté le : 31/07/2007 00:24
|
|
|
Re: Personnaliser les résultats de la recherche avec un template |
|
Semi pro
Inscrit: 13/12/2004 11:28
De Lyon
|
Citation : Burning a écrit: Vi t'as tout compris : suffit de faire des copiés-collés (c'est déjà en place ici)
... fier comme s'il avait un bar-tabac le Burning
Merci à Christian d'avoir extrait ce topic et à rlankford pour le hack !
@+
Sympa le nouveau Xoops4Noobs, je le verrai bien s'étirer jusqu'en bas
Posté le : 31/07/2007 00:33
|
|
Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.
|