Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5

Problème de lien suivant, précédent dans les articles
#11

Hum... oui, j'avais déjà vu.
Et franchement, j'ai vraiment du mal...

Bon, après avoir bien transpiré, j'ai un truc qui semble fonctionner... mais Bess, pourrais-tu me dire si le code te convient mieux comme ça ?

Code :
[== Indéfini ==]
$gCms = cmsms();
$db = &$gCms->GetDb();

if(isset($gCms->modules))
{
    $mod = $gCms->modules['News']['object'];
} else {
    $modops = cmsms()->GetModuleOperations();
    $mod = $modops->get_module_instance('News');
}

$pageid = ($_REQUEST['pageid']) ? $_REQUEST['pageid'] : $params['pageid'];
$currdate = $params['currdate'];
if(!$currdate) return;

// on crée la requête SQL, en s'assurant de se libérer du préfixe cms_ qui peut différer d'une installation à une autre
$sql = 'SELECT nom,prenom,email FROM '.cms_db_prefix().'`module_monmodule_user` ORDER BY `nom`';

// get all news articles PUBLISHED sorted by ascending date
$query_next = "SELECT news_id,news_title,news_url FROM  ".cms_db_prefix()."module_news WHERE news_date > ? AND status = 'published' ORDER BY news_date ASC LIMIT 1";
$query_prev = "SELECT news_id,news_title,news_url FROM ".cms_db_prefix()."module_news WHERE news_date < ? AND status = 'published' ORDER BY news_date DESC  LIMIT 1";
$query_uri = "SELECT news_id,news_title,news_url FROM ".cms_db_prefix()."module_news WHERE news_date = ? AND status = 'published' ";
$result_next = &$db->GetRow($query_next,array($currdate));
$result_prev = &$db->GetRow($query_prev,array($currdate));
$result_uri = &$db->GetRow($query_uri,array($currdate));

if($result_next['news_id']) {
if($result_next['news_url']) {
$prettyurl = $result_next["news_url"];
}else{
$aliased_title = munge_string_to_url($result_next['news_title']);
$prettyurl = 'news/' . $result_next["news_id"] .'/'.$pageid."/$aliased_title";}
$next_uri = $mod->CreateLink('cntnt01', 'detail', $pageid, '', array('articleid' => $result_next["news_id"])  ,'', true, false, '', true, $prettyurl);
$next_text=$result_next["news_title"];
}else{
$next_uri = "";
}

if($result_prev['news_id']) {
if($result_prev['news_url']) {
$prettyurl = $result_prev["news_url"];
}else{
$aliased_title = munge_string_to_url($result_prev['news_title']);
$prettyurl = 'news/' . $result_prev["news_id"] .'/'.$pageid."/$aliased_title";}
$prev_uri = $mod->CreateLink('cntnt02', 'detail', $pageid, '', array('articleid' => $result_prev["news_id"]) ,'', true, false, '', true, $prettyurl);
$prev_text=$result_prev["news_title"];
}else{
$prev_uri = "";
}

if($result_uri['news_id']) {
if($result_uri['news_url']) {
$uri_page= $result_uri["news_url"];
}else{
$aliased_title = munge_string_to_url($result_uri['news_title']);
$uri_page= 'news/' . $result_uri["news_id"] .'/'.$pageid."/$aliased_title";}
}else{
$uri_page = "";
}

$smarty->assign('news_next_url', $next_uri);
$smarty->assign('news_next_text', $next_text);
$smarty->assign('news_prev_url', $prev_uri);
$smarty->assign('news_prev_text', $prev_text);
$smarty->assign('news_uri_page', $uri_page);

Merci encore à tous les 2 !
Répondre


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 3 visiteur(s)