Help - Search - Member List - Calendar
Full Version: [2.0 Portal] [Bloc]Sondage+
IPBR-FR > Entraide > Forums dédiés aux mods majeures > Portal
Fantome
Nom de fichier :: [Bloc]Sondage+
Auteur :: Fantome
Catégorie :: 2.0 Portal
Description ::
Affiche le dernier sondage sur tous les forums ou seulement ceux choisi (paramétrable dans l'ACP). Et cela en respectant les autorisations de lecture des topics.

Pour avoir les instruction avec une mise en page plus jolie aller voir le second post du sujet de support.

10/07/2005: corection d'un bug dans le choix du sondage.

Modifié Sun, Jul 10 2005 11:36 am

Voir le fichier
Fantome
Bloc Sondage+ pour IPB Portal

Affiche le dernier sondage sur tous les forums ou seulement ceux choisi (paramétrable par ACP). Et cela en respectant les autorisations de lecture des topics.

Ce bloc a était addapté depuis un bloc pour MyIbPortal créé par Simous.


Etape 1 : Ouvrir sources/ipbportal.php
Chercher
CODE
    $this->site_bits['affiliates']     = $this->_show_affiliates();
Ajouter en-dessous
CODE
    $this->site_bits['sondage']        = $this->_show_sondage();


Chercher
CODE
}

?>
Ajouter au-dessus
CODE
/*-------------------------------------------------------------------------*/
// Bloc Sondage
/*-------------------------------------------------------------------------*/

function _show_sondage()
{
global $ibforums, $DB, $std, $print;

$extra = "";
$sql = "";
$check = 0;

if ( ! $ibforums->vars['csite_sondage_show'] )
{
return;
}

if ( count($this->good_forum) <= 0 )
{
return;
}

if ( $ibforums->vars['csite_sondage_forum'] != "" ) {
$forum = explode(',', $ibforums->vars['csite_sondage_forum'] );
$forumid = array_intersect ($this->good_forum, $forum);
}
else {
$forumid = $this->good_forum;
}

$qe = "t.forum_id IN(".implode(',', $forumid ).") AND ";

$DB->query( "SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
WHERE ".$qe."p.tid=t.tid
ORDER BY p.start_date DESC
LIMIT 1", 1 );

//-----------------------------------------
// Pour le suite c'est la copie de la fonction _show_poll
//-----------------------------------------

$poll = $DB->fetch_row();

if ( ! $poll['pid'] )
{
return;
}

$poll['poll_question'] = $poll['poll_question'] ? $poll['poll_question'] : $poll['title'];

//-----------------------------------------
// Can we vote?
//-----------------------------------------

if ( $poll['state'] == 'closed' )
{
$check = 1;
$poll_footer = $ibforums->lang['poll_finished'];
}
else if (! $ibforums->member['id'] )
{
$check = 1;
$poll_footer = $ibforums->lang['poll_noguest'];
}
else if ( $poll['member_voted'] )
{
$check = 1;
$poll_footer = $ibforums->lang['poll_voted'];
}
else if ( ($poll['starter_id'] == $ibforums->member['id']) and ($ibforums->vars['allow_creator_vote'] != 1) )
{
$check = 1;
$poll_footer = $ibforums->lang['poll_novote'];
}
else
{
$check = 0;
$poll_footer = $this->html->tmpl_poll_vote();
}

//-----------------------------------------
// Show it
//-----------------------------------------

if ($check == 1)
{
//-----------------------------------------
// Show the results
//-----------------------------------------

$total_votes = 0;

$html = $this->html->tmpl_poll_header($poll['poll_question'], $poll['tid']);

$poll_answers = unserialize(stripslashes($poll['choices']));

reset($poll_answers);
foreach ($poll_answers as $entry)
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];

$total_votes += $votes;

if ( strlen($choice) < 1 )
{
continue;
}

if ($ibforums->vars['poll_tags'])
{
$choice = $this->parser->parse_poll_tags($choice);
}
if ( $ibforums->vars['post_wordwrap'] > 0 )
{
$choice = $this->parser->my_wordwrap( $choice, $ibforums->vars['post_wordwrap']);
}

$percent = $votes == 0 ? 0 : $votes / $poll['votes'] * 100;
$percent = sprintf( '%.2f' , $percent );
$width = $percent > 0 ? floor( round( $percent ) * ( 150 / 100 ) ) : 0;

$html .= $this->html->tmpl_poll_result_row($votes, $id, $choice, $percent, $width);
}
}
else
{
$poll_answers = unserialize(stripslashes($poll['choices']));
reset($poll_answers);

//-----------------------------------------
// Show poll form
//-----------------------------------------

$html = $this->html->tmpl_poll_header($poll['poll_question'], $poll['tid']);

foreach ($poll_answers as $entry)
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];

$total_votes += $votes;

if ( strlen($choice) < 1 )
{
continue;
}

if ($ibforums->vars['poll_tags'])
{
$choice = $this->parser->parse_poll_tags($choice);
}
if ( $ibforums->vars['post_wordwrap'] > 0 )
{
$choice = $this->parser->my_wordwrap( $choice, $ibforums->vars['post_wordwrap']);
}

$html .= $this->html->tmpl_poll_choice_row($id, $choice);
}

}

$html .= $this->html->tmpl_poll_footer($poll_footer, sprintf( $ibforums->lang['poll_total_votes'], $total_votes ), $poll['tid'] );

return $html;
}


Enregistrer et Fermer sources/ipbportal.php


Etape 2 : Aller dans l'ACP de votre forum
Etape 2.1 : Dans System Settings > View All General Setting > Import an XML settings file
Puis Puis importer les settings contenue dans le fichier ipb_settings_bloc_sondage+.xml (dans le zip)
Configuré les options du bloc dans les paramétres du portail.

Etape 2.2 :Dans Skins & Templates > Skin Manager > IPB Default Skin > Edit Root Skin Template HTML
Puis IPB Portal > csite_skeleton_template
Ajouter
CODE
<!--CS.TEMPLATE.SONDAGE-->
Entre <!--Main Content--> et <!--End Main Content-->
Valider en cliquant sur Save Template Bit(s)


FIN
magic.mimi
Une question :

Bien que j'ai mis dans la liste ne numéro de forum d'un nouveau sondage que je viens de mettre, l'ancien d'un autre forum reste toujours visible.

Je croyais que c'était le dernier sondage qui s'affichait ?

Pourrait tu explique les options quand on clique sur "edit" du pca portail ?

jean-mi
Fantome
effectivement je pense qu'il y as une erreur dans la requéte sql.

il faut relmplacer
CODE
SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
WHERE ".$qe."p.tid=t.tid
par
CODE
SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
WHERE ".$qe."p.tid=t.tid
ORDER BY p.start_date DESC
LIMIT 1


voila ça devrais marcher je pense.

Tient moi au courant pour que je mette a jour le fichier.

Merci @+
magic.mimi
QUOTE
Tient moi au courant pour que je mette a jour le fichier.

Merci @+
*




Parse error: parse error, unexpected T_STRING in /home/croquela/www/aa_forum/sources/ipbportal.php on line 1204 =


j'ai donc remplacer :

CODE
$DB->query( "SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
   FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
   LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
   WHERE ".$qe."p.tid=t.tid", 1 );


par :

CODE
$DB->query( "SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted

   FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p

   LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)

   WHERE ".$qe."p.tid=t.tid",
   ORDER BY p.start_date DESC LIMIT 1 , 1  );


J'ai bon ou je suis pas bien reveillé ? rolleyes.gif


je comprend bien que l'erreur vient d'un "signe" de fermeture ou non fermeture. Mais c'est tout !

jean-mi
Fantome
faux il fallait mettre
CODE
$DB->query( "SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
WHERE ".$qe."p.tid=t.tid
ORDER BY p.start_date DESC
LIMIT 1", 1 );


j'aurais du mettre la ligne entière wink.gif
magic.mimi
QUOTE(Fantome @ dimanche 10 juillet 2005 à 09:41)
faux il fallait mettre
CODE
$DB->query( "SELECT t.tid, t.title, t.state, t.last_vote, p.*, v.member_id as member_voted
FROM ".SQL_PREFIX."topics t, ".SQL_PREFIX."polls p
LEFT JOIN ".SQL_PREFIX."voters v ON (v.member_id=".intval($ibforums->member['id'])." and v.tid=t.tid)
WHERE ".$qe."p.tid=t.tid
ORDER BY p.start_date DESC
LIMIT 1", 1 );


j'aurais du mettre la ligne entière wink.gif
*



Cela marche ! comprend pas j'ai été le seul a installer ce bloc ? ou alors tous les autres n'utilisaient qu'un seul forum ?
Fantome
ok ben je vais coriger le zip et le sujet.
Merci

EDIT: MaJ effectuer.
magic.mimi
QUOTE(Fantome @ dimanche 10 juillet 2005 à 11:18)
ok ben je vais coriger le zip et le sujet.
Merci

EDIT: MaJ effectuer.
*




si j'ai bien compris je fais "testeur au noir !" blink.gif biggrin.gif

jean-mi
Pas 3:16
Bonjour je vien t'installé le portail qu'ont peux voir http://www.wrestlingmediainfo.com/index.php il est en test pour le moment.

Bon mon problème c'est au niveau de l'installation du bloc sondage.

Le problème c'est quand j'importe le fichier ipb_settings_sondage+

Ça me donne cela comme erreur: blink.gif

[2] move_uploaded_file(): Unable to move '/tmp/phpHiztik' to './uploads/ipb_settings_sondage+.xml' (Line: 209 of /sources/admin/admin_functions.php)

J'ai due faire de quoi de mal. wink.gif

Merci
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.