Accueil
Forum PHPBoost
Personnalisation
Personnalisation fonctionnelle
Editeur dans la partie admin d'un module
Forum PHPBoost
Personnalisation
Personnalisation fonctionnelle
Editeur dans la partie admin d'un module
Forum PHPBoost
• Index
Reprise du message précédent
Tu as choisi quelle solution ?
Tu as choisi quelle solution ?
Dans mon php :
$Template->assign_block_vars('edit', array(
'KERNEL_EDITOR' => display_editor(),
Dans mon tpl :
{edit.KERNEL_EDITOR}
$Template->assign_block_vars('edit', array(
'KERNEL_EDITOR' => display_editor(),
Dans mon tpl :
{edit.KERNEL_EDITOR}
Colles les deux fichiers en question ici stp.
PHP :
Code PHP :
Code PHP :
if (!empty($_POST['update']) && !empty($id_post)) // Mise a jour du contenu { $idtab = retrieve(POST, 'tab', 0); $idlicence = retrieve(POST, 'licence', 0); $content = retrieve(POST, 'content', '', TSTRING_PARSE); //On met à jour if (!empty($content)) { $Sql->query_inject("UPDATE " . PREFIX . "tab_content SET idtab = '" . $idtab . "', idlicence = '" . $idlicence . "', contents = '" . $content . "' WHERE id = '" . $id_post . "'", __LINE__, __FILE__); redirect(HOST . SCRIPT); } else redirect(HOST . DIR . '/tab/admin_tab_content.php?id= ' . $id_post . '&error=incomplete#errorh'); } elseif (!empty($id)) // Affichage de l'édition { $Template->set_filenames(array( 'admin_tab_content_management'=> 'tab/admin_tab_content_management.tpl' )); $row = $Sql->query_array(PREFIX . 'tab_content', '*', "WHERE id = '" . $id . "'", __LINE__, __FILE__); $Template->assign_block_vars('edit', array( 'KERNEL_EDITOR' => display_editor(), 'TOKEN' => $Session->get_token(), 'CONTENT' => $row['contents'], 'IDCONTENT' => $row['id'] )); $idlicence = $row['idlicence']; $idtab = $row['idtab']; //Permis $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab_licence", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == $idlicence) ? 'selected="selected"' : ''; $Template->assign_block_vars('edit.select', array( 'LICENCE' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); //Onglet $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == $idtab) ? 'selected="selected"' : ''; $Template->assign_block_vars('edit.select', array( 'TAB' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); $Template->assign_vars(array( 'L_REQUIRE_LICENCE' => $LANG['require_title'], 'L_REQUIRE_PAGE' => $LANG['require_cat'], 'L_LICENCE_MANAGEMENT' => $LANG['tab_management'], 'L_ADD_LICENCE' => $LANG['add_tab'], 'L_EDIT_TAB' => $LANG['edit_tab'], 'L_REQUIRE' => $LANG['require'], 'L_LICENCE' => $LANG['title'], 'L_PAGE' => $LANG['category'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'] )); $Template->pparse('admin_tab_content_management'); } else // Affichage de base { $Template->set_filenames(array( 'admin_tab_content_management'=> 'tab/admin_tab_content_management.tpl' )); $Template->assign_vars(array( 'L_UNTIL' => $LANG['until'], 'L_REQUIRE_TITLE' => $LANG['require_title'], 'L_REQUIRE_TEXT' => $LANG['require_text'], 'L_REQUIRE_CAT' => $LANG['require_cat'], 'L_TAB_MANAGEMENT' => $LANG['tab_management'], 'L_ADD_TAB' => $LANG['add_tab'], 'L_CAT_TAB' => $LANG['category_tab'], 'L_EDIT_TAB' => $LANG['edit_tab'], 'L_REQUIRE' => $LANG['require'], 'L_TITLE' => $LANG['title'], 'L_CATEGORY' => $LANG['category'], 'L_TEXT' => $LANG['content'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'] )); $Template->assign_block_vars('list', array( 'KERNEL_EDITOR' => display_editor() )); $result = $Sql->query_while("SELECT tl.name licence, tc.id, tp.name page, tt.name tab FROM " . PREFIX . "tab_content tc LEFT JOIN " . PREFIX . "tab tt ON tt.id = tc.idtab LEFT JOIN " . PREFIX . "tab_licence tl ON tl.id = tc.idlicence LEFT JOIN " . PREFIX . "tab_page tp ON tp.id = tl.idpage ORDER by tp.id ASC" , __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $Template->assign_block_vars('list.content', array( 'LICENCE' => $row['licence'], 'TAB' => $row['tab'], 'IDCONTENT' => $row['id'], 'PAGE' => $row['page'] )); } $Sql->query_close($result); //Permis $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab_licence", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == 1) ? 'selected="selected"' : ''; $Template->assign_block_vars('select', array( 'LICENCE' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); //Titre onglet $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == 1) ? 'selected="selected"' : ''; $Template->assign_block_vars('select', array( 'TAB' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); $Template->pparse('admin_tab_content_management'); }
TPL :
Code TEMPLATE :
Code TEMPLATE :
<div id="admin_contents"> # START list # <script type="text/javascript"> <!-- function check_form(){ # IF C_BBCODE_TINYMCE_MODE # tinyMCE.triggerSave(); # ENDIF # if(document.getElementById('content').value == "") { alert("Il faut mettre un contenu"); return false; } return true; } function Confirm() { return confirm("Supprimer le contenu ?"); } --> </script> <table class="module_table"> <tr style="text-align:center;"> <th> Titre de l'onglet </th> <th> Permis </th> <th> Page </th> <th> {L_UPDATE} </th> <th> Supprimer </th> </tr> # START list.content # <tr style="text-align:center;"> <td class="row2"> {list.content.TAB} </td> <td class="row2"> {list.content.LICENCE} </td> <td class="row2"> {list.content.PAGE} </td> <td class="row2"> </td> <td class="row2"> </td> </tr> # END list.content # </table> <!-- Ajout d'un contenu --> <form action="admin_tab_content.php?token={TOKEN}" name="form" method="post" style="margin:auto;" onsubmit="return check_form();" class="fieldset_content"> <fieldset> <dl> <select id="licence" name="licence"> # START select # {select.LICENCE} # END select # </select> </dl> <dl> <select id="tab" name="tab"> # START select # {select.TAB} # END select # </select> </dl> {list.KERNEL_EDITOR} </fieldset> <fieldset class="fieldset_submit"> <input type="submit" name="valid" value="Ajouter" class="submit" /> <input type="reset" value="{L_RESET}" class="reset" /> </fieldset> </form> # END list # # START edit # <script type="text/javascript"> <!-- var theme = '{THEME}'; --> </script> <script type="text/javascript"> <!-- function check_form(){ # IF C_BBCODE_TINYMCE_MODE # tinyMCE.triggerSave(); # ENDIF # if(document.getElementById('content').value == "") { alert("Il faut mettre un contenu"); return false; } return true; } --> </script> <form action="admin_tab_content.php?token={TOKEN}" name="form" method="post" style="margin:auto;" onsubmit="return check_form();" class="fieldset_content"> <fieldset> <dl> <select id="licence" name="licence"> # START edit.select # {select.LICENCE} # END edit.select # </select> </dl> <dl> <select id="tab" name="tab"> # START edit.select # {select.TAB} # END edit.select # </select> </dl> {edit.KERNEL_EDITOR} </fieldset> <fieldset class="fieldset_submit"> <input type="hidden" name="id" value="{edit.IDCONTENT}" class="submit" /> <input type="submit" name="update" value="{L_UPDATE}" class="submit" /> </fieldset> </form> # END edit # </div>
Ok et c'est dans quel cadre que tu souhaites afficher l'éditeur BBCode ? L'édition, l'ajout ?
Oui c'est ça.
Quand j'ajoute un contenu ou quand je veux en éditer un.
J'ai besoin des puces, des retours chario, et comme ce n'est pas moi qui vais par la suite administrer le site et que le contenu va bouger....
Quand j'ajoute un contenu ou quand je veux en éditer un.
J'ai besoin des puces, des retours chario, et comme ce n'est pas moi qui vais par la suite administrer le site et que le contenu va bouger....
Code PHP :
Code TPL :
$Template->set_filenames(array( 'admin_tab_content_management'=> 'tab/admin_tab_content_management.tpl' )); if (!empty($_POST['update']) && !empty($id_post)) // Mise a jour du contenu { $idtab = retrieve(POST, 'tab', 0); $idlicence = retrieve(POST, 'licence', 0); $content = retrieve(POST, 'content', '', TSTRING_PARSE); //On met à jour if (!empty($content)) { $Sql->query_inject("UPDATE " . PREFIX . "tab_content SET idtab = '" . $idtab . "', idlicence = '" . $idlicence . "', contents = '" . $content . "' WHERE id = '" . $id_post . "'", __LINE__, __FILE__); redirect(HOST . SCRIPT); } else redirect(HOST . DIR . '/tab/admin_tab_content.php?id= ' . $id_post . '&error=incomplete#errorh'); } elseif (!empty($id)) // Affichage de l'édition { $row = $Sql->query_array(PREFIX . 'tab_content', '*', "WHERE id = '" . $id . "'", __LINE__, __FILE__); $Template->assign_block_vars('edit', array( 'TOKEN' => $Session->get_token(), 'CONTENT' => $row['contents'], 'IDCONTENT' => $row['id'] )); $idlicence = $row['idlicence']; $idtab = $row['idtab']; //Permis $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab_licence", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == $idlicence) ? 'selected="selected"' : ''; $Template->assign_block_vars('edit.select', array( 'LICENCE' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); //Onglet $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == $idtab) ? 'selected="selected"' : ''; $Template->assign_block_vars('edit.select', array( 'TAB' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); $Template->assign_vars(array( 'L_REQUIRE_LICENCE' => $LANG['require_title'], 'L_REQUIRE_PAGE' => $LANG['require_cat'], 'L_LICENCE_MANAGEMENT' => $LANG['tab_management'], 'L_ADD_LICENCE' => $LANG['add_tab'], 'L_EDIT_TAB' => $LANG['edit_tab'], 'L_REQUIRE' => $LANG['require'], 'L_LICENCE' => $LANG['title'], 'L_PAGE' => $LANG['category'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'] )); } else // Affichage de base { $Template->assign_vars(array( 'L_UNTIL' => $LANG['until'], 'L_REQUIRE_TITLE' => $LANG['require_title'], 'L_REQUIRE_TEXT' => $LANG['require_text'], 'L_REQUIRE_CAT' => $LANG['require_cat'], 'L_TAB_MANAGEMENT' => $LANG['tab_management'], 'L_ADD_TAB' => $LANG['add_tab'], 'L_CAT_TAB' => $LANG['category_tab'], 'L_EDIT_TAB' => $LANG['edit_tab'], 'L_REQUIRE' => $LANG['require'], 'L_TITLE' => $LANG['title'], 'L_CATEGORY' => $LANG['category'], 'L_TEXT' => $LANG['content'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'] )); $result = $Sql->query_while("SELECT tl.name licence, tc.id, tp.name page, tt.name tab FROM " . PREFIX . "tab_content tc LEFT JOIN " . PREFIX . "tab tt ON tt.id = tc.idtab LEFT JOIN " . PREFIX . "tab_licence tl ON tl.id = tc.idlicence LEFT JOIN " . PREFIX . "tab_page tp ON tp.id = tl.idpage ORDER by tp.id ASC" , __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $Template->assign_block_vars('list.content', array( 'LICENCE' => $row['licence'], 'TAB' => $row['tab'], 'IDCONTENT' => $row['id'], 'PAGE' => $row['page'] )); } $Sql->query_close($result); //Permis $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab_licence", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == 1) ? 'selected="selected"' : ''; $Template->assign_block_vars('select', array( 'LICENCE' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); //Titre onglet $i = 0; $result = $Sql->query_while("SELECT * FROM " . PREFIX . "tab", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $selected = ($row['id'] == 1) ? 'selected="selected"' : ''; $Template->assign_block_vars('select', array( 'TAB' => '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>' )); $i++; } $Sql->query_close($result); //Gestion erreur. $get_error = retrieve(GET, 'error', ''); if ($get_error == 'incomplete') $Errorh->handler($LANG['e_incomplete'], E_USER_NOTICE); elseif ($i == 0) //Aucune catégorie => alerte. $Errorh->handler($LANG['require_cat_create'], E_USER_WARNING); } $Template->assign_vars(array( 'KERNEL_EDITOR' => display_editor() )); $Template->pparse('admin_tab_content_management');
Code TPL :
<div id="admin_contents"> # START list # <script type="text/javascript"> <!-- function check_form(){ # IF C_BBCODE_TINYMCE_MODE # tinyMCE.triggerSave(); # ENDIF # if(document.getElementById('content').value == "") { alert("Il faut mettre un contenu"); return false; } return true; } function Confirm() { return confirm("Supprimer le contenu ?"); } --> </script> <table class="module_table"> <tr style="text-align:center;"> <th> Titre de l'onglet </th> <th> Permis </th> <th> Page </th> <th> {L_UPDATE} </th> <th> Supprimer </th> </tr> # START list.content # <tr style="text-align:center;"> <td class="row2"> {list.content.TAB} </td> <td class="row2"> {list.content.LICENCE} </td> <td class="row2"> {list.content.PAGE} </td> <td class="row2"> <a href="admin_tab_content.php?id={list.content.IDCONTENT}"><img src="../templates/{THEME}/images/{LANG}/edit.png" alt="{L_UPDATE}" title="{L_UPDATE}" /></a> </td> <td class="row2"> <a href="admin_tab_content.php?delete=true&id={list.content.IDCONTENT}&token={TOKEN}" onclick="javascript:return Confirm();"><img src="../templates/{THEME}/images/{LANG}/delete.png" alt="{L_DELETE}" title="{L_DELETE}" /></a> </td> </tr> # END list.content # </table> <br /><br /> <!-- Ajout d'un contenu --> <form action="admin_tab_content.php?token={TOKEN}" name="form" method="post" style="margin:auto;" onsubmit="return check_form();" class="fieldset_content"> <fieldset> <legend>Ajout d'un contenu</legend> <p>{L_REQUIRE}</p> <dl> <dt><label for="licence">* Permis</label></dt> <dd><label> <select id="licence" name="licence"> # START select # {select.LICENCE} # END select # </select> </label></dd> </dl> <dl> <dt><label for="tab">* Onglet</label></dt> <dd><label> <select id="tab" name="tab"> # START select # {select.TAB} # END select # </select> </label></dd> </dl> <label for="content">* {L_TEXT}</label> {KERNEL_EDITOR} <label><textarea rows="20" cols="86" id="content" name="content"></textarea></label> <br /><br /> </fieldset> <fieldset class="fieldset_submit"> <legend>Ajouter</legend> <input type="submit" name="valid" value="Ajouter" class="submit" /> <input type="reset" value="{L_RESET}" class="reset" /> </fieldset> </form> # END list # # START edit # <script type="text/javascript"> <!-- var theme = '{THEME}'; --> </script> <script type="text/javascript"> <!-- function check_form(){ # IF C_BBCODE_TINYMCE_MODE # tinyMCE.triggerSave(); # ENDIF # if(document.getElementById('content').value == "") { alert("Il faut mettre un contenu"); return false; } return true; } --> </script> <form action="admin_tab_content.php?token={TOKEN}" name="form" method="post" style="margin:auto;" onsubmit="return check_form();" class="fieldset_content"> <fieldset> <legend>Editer un contenu</legend> <p>{L_REQUIRE}</p> <dl> <dt><label for="licence">* Permis</label></dt> <dd><label> <select id="licence" name="licence"> # START edit.select # {select.LICENCE} # END edit.select # </select> </label></dd> </dl> <dl> <dt><label for="tab">* Onglet</label></dt> <dd><label> <select id="tab" name="tab"> # START edit.select # {select.TAB} # END edit.select # </select> </label></dd> </dl> <label for="content">* {L_TEXT}</label> {KERNEL_EDITOR} <label><textarea rows="20" cols="86" id="content" name="content">{edit.CONTENT}</textarea></label> <br /><br /> </fieldset> <fieldset class="fieldset_submit"> <legend>{L_UPDATE}</legend> <input type="hidden" name="id" value="{edit.IDCONTENT}" class="submit" /> <input type="submit" name="update" value="{L_UPDATE}" class="submit" /> </fieldset> </form> # END edit # </div>
• Index
1 Utilisateur en ligne :: 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne: Aucun membre connecté
Utilisateur en ligne: Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie













Les partenaires
Le projet PHPBoost
Contribuer au Projet
Support PHPBoost