Code source pour générer une url propre avec sh404sef pour le composant ckforms
La prise en compte correct du SEF par ckforms passe par la modification d'une vue dans components/com_ckforms/views/ckforms/view.html.php ligne 34 :
<?php
//remplacer $formLink = "index.php?option=com_ckforms&view=ckforms&task=send&id=".$ckforms->id; par
$formLink = JRoute::_("index.php?option=com_ckforms&view=ckforms&task=send&id=".$ckforms->id);
?>
Ensuite il faut créer deux fichiers :
fichier de langue com_ckforms.php dans /administrator/components/com_sh404sef/language/plugins
<?php
if (!defined('_JEXEC')) die('Direct Access to this location is not allowed.');
// {shSourceVersionTag: Version 1.0 - 2009-11-21}
// français
$sh_LANG['fr']['_COM_SEF_CKFORMS_NAME'] = 'formulaires';
$sh_LANG['fr']['_COM_SEF_VIEWDATA'] = 'resultats';
$sh_LANG['fr']['_COM_SEF_SENDDATA'] = 'envois';
$sh_LANG['en']['_COM_SEF_CKFORMS_NAME'] = 'forms';
$sh_LANG['en']['_COM_SEF_VIEWDATA'] = 'results';
$sh_LANG['fr']['_COM_SEF_SENDDATA'] = 'send';
?>
fichier de plugins com_ckforms.php dans/components/com_sh404sef/sef_ext
<?php
/**
* sh404SEF support for com_ckforms component.
* Author : nl
* contact : nico@24bis.com
*
* {shSourceVersionTag: Version 1.01 - 2009-11-22}
*
* This is a sample sh404SEF native plugin file
*
*/
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
// ------------------ standard plugin initialize function - don't change ---------------------------
global $sh_LANG;
$sefConfig = & shRouter::shGetConfig();
$shLangName = '';
$shLangIso = '';
$title = array();
$shItemidString = '';
$dosef = shInitializePlugin( $lang, $shLangName, $shLangIso, $option);
if ($dosef == false) return;
// ------------------ standard plugin initialize function - don't change ---------------------------
// ------------------ load language file - adjust as needed ----------------------------------------
$shLangIso = shLoadPluginLanguage( 'com_ckforms', $shLangIso, '_COM_SEF_CKFORMS_NAME');
// ------------------ load language file - adjust as needed ----------------------------------------
// remove common URL from GET vars list, so that they don't show up as query string in the URL
shRemoveFromGETVarsList('option');
shRemoveFromGETVarsList('lang');
if (!empty($Itemid))
shRemoveFromGETVarsList('Itemid');
$view = isset($view) ? @$view : null;
$task = isset($task) ? @$task : null;
$Itemid = isset($Itemid) ? @$Itemid : null;
$id = isset($id) ? @$id : null;
switch ($task) {
case 'send':
$title[] = $sh_LANG[$shLangIso]['_COM_SEF_SENDDATA'];
shRemoveFromGETVarsList('task');
break;
case 'captcha':
$dosef = false;
break;
}
switch ($view) { //index.php?option=com_ckforms&view=ckforms&task=send&id=1
case "ckformsdata":
$controller = isset($controller) ? @$controller : null;
$layout = isset($layout) ? @$layout : null;
$title[] = $sh_LANG[$shLangIso]['_COM_SEF_VIEWDATA'];
$id = str_replace("f","",$id);
if (!empty($id)) {
$q = 'SELECT id, title FROM #__ckforms WHERE id = '.$id;
$database->setQuery($q);
$data = $database->loadObject( ((shTranslateUrl($option, $shLangName)) ? true:false) );
if ($data) {
$title[] = $data->title;
shRemoveFromGETVarsList('id');
}
}
shRemoveFromGETVarsList('view');
shRemoveFromGETVarsList('controller');
shRemoveFromGETVarsList('layout');
break;
case "ckforms":
$title[] = $sh_LANG[$shLangIso]['_COM_SEF_CKFORMS_NAME'];
if (!empty($id)) {
$q = 'SELECT id, title FROM #__ckforms WHERE id = '.$id;
$database->setQuery($q);
$data = $database->loadObject( ((shTranslateUrl($option, $shLangName)) ? true:false) );
if ($data) {
$title[] = $data->title;
shRemoveFromGETVarsList('id');
}
}
shRemoveFromGETVarsList('view');
break;
}
//$title[] = '/';
// ------------------ standard plugin finalize function - don't change ---------------------------
if ($dosef){
$string = shFinalizePlugin( $string, $title, $shAppendString, $shItemidString,
(isset($limit) ? @$limit : null), (isset($limitstart) ? @$limitstart : null),
(isset($shLangName) ? @$shLangName : null));
}
// ------------------ standard plugin finalize function - don't change ---------------------------
?>