Bonjour,
J'aurais besoin d'un coup de main SVP.
J' ai un site qui fonctionne sur oscomerce, j' ai ajouter le module AP URL Rewriting.
j'aimerais modifier la fonction tep_href_link().
faire un test pour identifier les pages suivantes a partir des URL:
-Homepage
-Les pages insitututionnelles
-Pages mosaiques
-Pages produits
Pour faire des regles de réecriture differentes pour chaque type de page identifiée.
Voila le code :
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $rewrite_name = true) {
global $request_type, $session_started, $SID;
if (!tep_not_null($page)) {
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
}
if ($connection == 'NONSSL') {
$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
} elseif ($connection == 'SSL') {
if (ENABLE_SSL == true) {
$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
} else {
$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
}
} else {
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');
}
////
// AP URL Rewriting
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) && ($rewrite_name == true) ) {
if (tep_not_null($parameters)) {
foreach (explode("&", $parameters) as $parameter) {
if (ereg("cPath=([0-9_]+)", $parameter, $regs)) $cPath = $regs[1];
if (ereg("products_id=([0-9]+)", $parameter, $regs)) $product_id = $regs[1];
if (ereg("manufacturers_id=([0-9]+)", $parameter, $regs)) $manufacturer_id = $regs[1];
}
if (defined('URL_SLOGAN')) $link .= URL_SLOGAN . '/';
if (tep_not_null($cPath)) {
$cPath_array = tep_parse_category_path($cPath);
foreach($cPath_array as $category_id) {
$category_name = tep_url_rewriting_cast(tep_get_categories_name($category_id));
if (tep_not_null($category_name)) $link .= $category_name . '/';
}
}
if (tep_not_null($manufacturer_id)) {
$manufacturer_name = tep_url_rewriting_cast(tep_get_manufacturers_name($manufacturer_id));
if (tep_not_null($manufacturer_name)) $link .= $manufacturer_name . '/';
}
if (tep_not_null($product_id)) {
$product_name = tep_url_rewriting_cast(tep_get_products_name($product_id));
if (tep_not_null($product_name)) $link .= $product_name . '/';
}
}
}
// AP URL Rewriting
////
if (tep_not_null($parameters)) {
$link .= $page . '?' . tep_output_string($parameters);
$separator = '&';
} else {
$link .= $page;
$separator = '?';
}
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (tep_not_null($SID)) {
$_sid = $SID;
} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
$_sid = tep_session_name() . '=' . tep_session_id();
}
}
}
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
$link = str_replace('?', '/', $link);
$link = str_replace('&', '/', $link);
$link = str_replace('=', '/', $link);
$separator = '?';
}
if (isset($_sid)) {
$link .= $separator . tep_output_string($_sid);
}
return $link;
}
Toutes les idées sont la bienveune.
Merci d'avance.