osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> auto-completion
audioshop
posté 11 Sep 2009, 10:20
Message #1


Ceinture bleue OSC
Icône de groupe

Groupe : Membres
Messages : 983
Inscrit : 8-April 08
Lieu : strasbourg
Membre no 21429



Suite à l'improbable installation de la néanmoins superbe contrib Ajax-search, je me suis résigné à prendre ce que je trouvais sur google en moins complexe.
je me suis largement inspiré d'un code prévue pour wordpress mais qui fonctionne aussi sur oscommerce

Auto-completion wordpress

j'ai cependant un petit problème que je n'arrive pas à résoudre, l'auto-complétion fonctionne bien mais quand je clique sur le nom du produit je suis toujours redirigé vers l'index du site.

j'imagine qu'il doit manquer le lien vers l'article mais je ne trouve pas ou il doit être placé et le javascript c'est chaud pour moi.

un petit coup de main serais le bien venu merci

voici les code:

gettag.php

CODE
<?php
require('includes/application_top.php');
if (isset($_POST['keywords'])) {
$keywords = htmlentities($_POST['keywords']);
} else $keywords ='';

$query = "SELECT products_name

from products_description

WHERE products_name LIKE '$keywords%'";

$result = tep_db_query($query) or die();

echo '<ul>';
while ($data = mysql_fetch_array($result))
{
echo '<li><a href="#" onclick="selected(this.innerHTML);">'.htmlentities($data['products_name']).'</a></li>';
}

echo '</ul>';
?>


gettag.js
CODE
var myAjax = ajax();

function ajax() {
var ajax = null;
if (window.XMLHttpRequest) {
try {
ajax = new XMLHttpRequest();
}
catch(e) {}
}
else if (window.ActiveXObject) {
try {
ajax = new ActiveXObject("Msxm12.XMLHTTP");
}
catch (e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
return ajax;
}

function request(str) {
//N'oubliez pas de modifier le chemi du fichier au besoin.
myAjax.open("POST", "gettags.php");
myAjax.onreadystatechange = result;
myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
myAjax.send("keywords="+str);
}

function result() {
if (myAjax.readyState == 4) {
var liste = myAjax.responseText;
var cible = document.getElementById('tag_update').innerHTML = liste;
document.getElementById('tag_update').style.display = "block";
}
}

function selected(choice){
var cible = document.getElementById('s');
cible.value = choice;
document.getElementById('tag_update').style.display = "none";
}


Et mon fichier header_search.php qui ce trouve dans includes
CODE
<?php
/*
$Id: header_search.php,v 1.1.1.1 2003/04/06 12:15:21 wilt Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2001 osCommerce

Released under the GNU General Public License
## Patch bandeau Search dans Header : GniDhal gnidhal@free.fr ##
*/
?>
<!-- Header search //-->
<html>
<head>
<script type="text/javascript" src="gettags.js"></script>
<style type="text/css">
#tag_update {
display: block;
border-left: 1px solid #373737;
border-right: 1px solid #373737;
border-bottom: 1px solid #373737;
position:absolute;
z-index:1;
}

#tag_update ul {
margin: 0;
padding: 0;
list-style: none;
}

#tag_update li{
display:block;
clear:both;
}

#tag_update a {
width:200px;
display: block;
padding: .2em .3em;
text-decoration: none;
color: #fff;
background-color: #1B1B1C;
text-align: left;
}

#tag_update a:hover{
color: #fff;
background-color: #373737;
background-image: none;
}
</style>
</head>
<html>
<tr>
<td align="left" valign="top" class="BoxHeadingSearch" height="10" STYLE="background: #272727;">

<?php



$hide = tep_hide_session_id();
echo '<form name="quick_find" method="get" action="' . tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">' ;
echo $hide . BOX_SEARCH_TEXT . '&nbsp;<input type="text" name="keywords" size="10" maxlength="30" value="Mot cles" onfocus="if (this.value==\'Mot cles\') this.value=\'\'" onblur="if (this.value==\'\') this.value=\'Mot cles\'" onkeyup="request(this.value);" ' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '" style="width: ' . (BOX_WIDTH+45) . 'px; height:20px" style="background-color:aliceblue">

&nbsp;<input type="submit" value="Rechercher" /></div>&nbsp;&nbsp;&nbsp;<a class="BoxHeadingSearch" href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a><div id="tag_update"></form>' ;

?>

</td>
</td>
</tr>
<!-- Header_search_eof //-->
Go to the top of the page
 
SambaMambo
posté 11 Sep 2009, 10:37
Message #2


Ceinture bleue OSC
Icône de groupe

Groupe : Membres
Messages : 828
Inscrit : 27-May 05
Membre no 6003



qu'est-ce qu'il y a de dure à faire dans cette contrib : http://addons.oscommerce.com/info/6522
o_O
ca marche au poil en plus : http://www.advancewebsoft.com/demo/osc/
Go to the top of the page
 
audioshop
posté 11 Sep 2009, 11:00
Message #3


Ceinture bleue OSC
Icône de groupe

Groupe : Membres
Messages : 983
Inscrit : 8-April 08
Lieu : strasbourg
Membre no 21429



Ell n'a tous simplement pas fonctionné chez moi j'ai expliqué plus en détails le problème sur ce poste:

Ajax search

Essaye de l'installer chez toi et dit moi si tu te retrouve avec le même problème dans ce cas sa voudrais dire que c'est du au code de ma boutique.
Go to the top of the page
 
SambaMambo
posté 11 Sep 2009, 11:10
Message #4


Ceinture bleue OSC
Icône de groupe

Groupe : Membres
Messages : 828
Inscrit : 27-May 05
Membre no 6003



tu as testé celle la : http://addons.oscommerce.com/info/4144 ?
Go to the top of the page
 
mihelicjm
posté 13 Oct 2014, 12:56
Message #5


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 53
Inscrit : 9-November 04
Lieu : Charleroi
Membre no 3721



Un truc sympa aussi à faire sur create_account.php pour ceux intéressés par l'autocomplétion d'adresse via Google API v3... à peaufiner!
Juste avant le </head>:
CODE
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

Juste après le <body>:
CODE
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

Remplacer
CODE
<?php echo tep_draw_input_field('street_address') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?>

par
CODE
<?php echo tep_draw_input_field('street_address','','id="address" placeholder="Saisissez ici votre adresse" style="width: 440px;"') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?>

remplacer
CODE
<?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>

par
CODE
<?php echo tep_draw_input_field('postcode','','id="zip" style="width: 60px;"') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>

remplacer
CODE
<?php echo tep_draw_input_field('city') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?>

par
CODE
<?php echo tep_draw_input_field('city','','id="suburb" style="width: 250px;"') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?>

remplacer
CODE
echo tep_draw_pull_down_menu('state', $zones_array);
} else {
echo tep_draw_input_field('state');
}
} else {
echo tep_draw_input_field('state');

par
CODE
echo tep_draw_pull_down_menu('state', $zones_array);
} else {
echo tep_draw_input_field('state','','id="state" style="width: 250px;"');
}
} else {
echo tep_draw_input_field('state','','id="state" style="width: 250px;"');

et juste après </html> ajouter:
CODE
<script type="text/javascript">
var updateAddress = {
autocomplete: new google.maps.places.Autocomplete($("#address")[0], {}),
event: function(){
var self = this;
google.maps.event.addListener(self.autocomplete, 'place_changed', function() {
var place = self.autocomplete.getPlace(),
address = place.address_components,
streetAddress = '',
suburb = '',
state = '',
zip = '';
// country = '';

for (var i = 0; i < address.length; i++) {
var addressType = address[i].types[0];

if (addressType == 'subpremise') {
streetAddress += address[i].long_name + '/';
}
if (addressType == 'street_number') {
streetAddress += address[i].long_name + ' ';
}
if (address[i].types[0] == 'route') {
streetAddress += address[i].long_name;
}
if (addressType == 'locality') {
suburb = address[i].long_name;
}
if (addressType == 'administrative_area_level_1') {
state = address[i].long_name;
}
if (addressType == 'postal_code') {
zip = address[i].long_name;
}
// if (addressType == 'country') {
// country = address[i].long_name;
// }
}

// update the textboxes
$('#address').val(streetAddress);
$('#suburb').val(suburb);
$('#state').val(state);
$('#zip').val(zip);
// $('#country').val(country);
});

}
};

updateAddress.event();
</script>



--------------------
OsCommerce Bootstrap 2.3.4 visible ici >> Account_Balance_V4 >> Admin Notes with french v2.4_1 >> cronemul >> Extra Info to customer page in admin V1 >> extra_fields_v2_1 >> extra_images_v1-61 >> heardabout_1_25 >> mail-manager >> Menu deroulant date naissance Mini_Images_v2.0 >> Minimum_Order_Amount_1_4 >> Master Password 1_4 >> ordercheck >> Product Serial 1_0 >> PDF_Customer_Invoice_v1.0 >> points_rewardsV2.2beta >> RecoverCartSales 230 >> RMA_Returns_2-6 >> Suivi_colissimo >>
Go to the top of the page
 

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 16th April 2024 - 08:44
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)