Modification du formulaire de commentaire

Hello encore moi le casse-pied xD

Je voudrais savoir si il y avait un moyen d'obliger les gens à laisser une adresse mail pour écrire un commentaire dans un article.

A bientôt.

Réponses

  • bazooka07bazooka07 PluXml Lead Developer, Moderator

    Tu peux utiliser l'attribut required dans la balise <input>.
    Tu peux aussi utiliser email comme valeur pour type. Cela permet de filtrer la saisie et ça aide quand on utilise un smartphone :

    <input id="id_mail" name="mail" type="email" size="20" value="<?php $plxShow->comGet('mail',''); ?>" required />
    
  • D'accord mais du coup le mail n'est enregistré nul part du coup ?

  • petitpouyopetitpouyo Member
    novembre 2020 modifié

    Alors du coup après une recherche j'ai vu que les emails sont bien enregistrés dans les fichiers XML des commentaires.
    Pour les faire afficher sur le tableau de bord il faut modifier le fichier comments.php.
    Voici mes modifications:

    En dessous de la ligne 158 (author) j'ai rajouter ce code:
    <?php echo L_COMMENTS_LIST_AUTHOR ?><

    Et en dessous de la ligne 185 j'ai rajouter:

    echo '

    '.$plxAdmin->plxRecord_coms->f('mail').' ';

    Résultat final j'ai bien les adresses mails qui s'affichent sur le tableau admin, photo ci-contre: https://nimb.ws/qoDewW

  • bazooka07bazooka07 PluXml Lead Developer, Moderator

    Pour éviter de rajouter une colonne et répondre rapidement par courriel au visiteur, on peut faire comme ceci :

    <td class="author"><?php
        $author = $plxAdmin->plxRecord_coms->f('author');
        $mail = $plxAdmin->plxRecord_coms->f('mail');
        if(!empty($mail)) {
    ?><a href="mailto:<?= $mail ?>"><?= $author ?></a><?php
        } else {
            echo $author;
        }
    ?></td>
    

    On peut rajouter une colonne pour le site du visiteur. On peut préférer une colonne dédiée. Il est plus facile de parcourir le tableau; Avec une refactorisation, on aboutit à cela :

        <div class="scrollable-table">
            <table id="comments-table" class="full-width">
                <thead>
                    <tr>
                        <th class="checkbox"><input type="checkbox" onclick="checkAll(this.form, 'idCom[]')" /></th>
                        <th class="datetime"><?= L_COMMENTS_LIST_DATE ?></th>
    <?php
                $all = ($_SESSION['selCom'] == 'all');
                if($all) {
    ?>
                        <th class="status"><?= L_COMMENT_STATUS_FIELD ?></th>
    <?php
                }
    ?>
                        <th class="message"><?= L_COMMENTS_LIST_MESSAGE ?></th>
                        <th class="author"><?= L_COMMENTS_LIST_AUTHOR ?> <?= L_COMMENT_EMAIL_FIELD ?></th>
                        <th class="site"><?= L_COMMENT_SITE_FIELD ?></th>
                        <th class="action"><?= L_COMMENTS_LIST_ACTION ?></th>
                    </tr>
                </thead>
                <tbody>
    
    <?php
                # On va récupérer les commentaires
                $plxAdmin->getPage();
                $start = $plxAdmin->aConf['bypage_admin_coms']*($plxAdmin->page-1);
                $coms = $plxAdmin->getCommentaires($comSelMotif,'rsort',$start,$plxAdmin->aConf['bypage_admin_coms'],'all');
                if($coms) {
                    while($plxAdmin->plxRecord_coms->loop()) { # On boucle
                        $artId = $plxAdmin->plxRecord_coms->f('article');
                        $status = $plxAdmin->plxRecord_coms->f('status');
                        $id = $status.$artId.'.'.$plxAdmin->plxRecord_coms->f('numero');
                        $query = 'c=' . $id;
                        if(isset($_GET['a'])) {
                            $query .= '&a=' . $_GET['a'];
                        }
                        # On génère notre ligne
    ?>
                    <tr class="top type-<?= $plxAdmin->plxRecord_coms->f('type') ?>">
                        <td><input type="checkbox" name="idCom[]" value="<?= $id ?>" /></td>
                        <td class="datetime"><?= plxDate::formatDate($plxAdmin->plxRecord_coms->f('date')) ?></td>
    <?php
                    if($all) {
    ?>
                        <td class="status"><?= empty($status) ? L_COMMENT_ONLINE : L_COMMENT_OFFLINE ?></td>
    <?php
                    }
    ?>
                        <td class="wrap"><?= nl2br($plxAdmin->plxRecord_coms->f('content')) ?></td>
                        <td class="author"><?php
                        $author = $plxAdmin->plxRecord_coms->f('author');
                        $mail = $plxAdmin->plxRecord_coms->f('mail');
                        if(!empty($mail)) {
    ?><a href="mailto:<?= $mail ?>"><?= $author ?></a><?php
                        } else {
                            echo $author;
                        }
    ?></td>
                        <td class="site"><?php
                        $site = $plxAdmin->plxRecord_coms->f('site');
                        if(!empty($site)) {
    ?><a href="<?= $site ?>" target="_blank"><?= $site ?></a><?php
                        } else {
                            echo '&nbsp;';
                        }
    ?></td>
                        <td class="action">
                            <a href="comment_new.php?<?= $query ?>" title="<?= L_COMMENT_ANSWER ?>"><?= L_COMMENT_ANSWER ?></a>
                            <a href="comment.php?<?= $query ?>" title="<?= L_COMMENT_EDIT_TITLE ?>"><?= L_COMMENT_EDIT ?></a>
                            <a href="article.php?a=<?= $artId ?>" title="<?= L_COMMENT_ARTICLE_LINKED_TITLE ?>"><?= L_COMMENT_ARTICLE_LINKED ?></a>
                        </td>
                    </tr>
    <?php
                    }
                } else { # Pas de commentaires
    ?>
                    <tr>
                        <td colspan="5" class="center"><?= L_NO_COMMENT ?></td>
                    </tr>
    <?php
                }
                ?>
                </tbody>
            </table>
        </div>
    

    Il faut modifier le fichier core/admin/css/theme.css pour la nouvelle colonne status à la ligne 324 :

    #articles-table td:nth-child(4),
    #comments-table td:nth-child(4),
    #medias-table td:nth-child(3),
    #plugins-table td:nth-child(3) {
        width: 100%;
        min-width: 200px;
        /* Mozilla, since 1999 */
        white-space: -moz-pre-wrap !important;
        /*Chrome & Safari */
        white-space: -webkit-pre-wrap;
        /* Opera 4-6 */
        white-space: -pre-wrap;
        /* Opera 7 */
        white-space: -o-pre-wrap;
        /* css-3 */
        white-space: pre-wrap;
        /* Internet Explorer 5.5+ */
        word-wrap: break-word;
        word-break: break-all;
        white-space: normal;
    }
    
  • Salut @bazooka07 tu fais pas les choses à moitié lol ta personnalisation est sympa.

    Dis moi comment tu utilise quelle balise pour écrire en code sur le forum ?

  • bazooka07bazooka07 PluXml Lead Developer, Moderator
  • bazooka07bazooka07 PluXml Lead Developer, Moderator
    novembre 2020 modifié

    Pour ceux qui savent se servir de git :
    Pour PluXml-5.8.4

    git clone -b comments-list-201101 https://github.com/kazimentou/PluXml.git
    

    Pour PluXml-master

    git clone -b comments-list-201102 https://github.com/kazimentou/PluXml.git
    

    il y a des conflits à régler pour un git rebase entre les 2 branches

  • Super cool merci ! Tu es calé sur PluXml c'est impressionnant

Connectez-vous ou Inscrivez-vous pour répondre.